[Question]
      [
Given a string, consisting of a prefix and then "illion", convert this number into standard form.
For example:
```
"million" -> 10^6
"trillion" -> 10^12
"quattuordecillion" -> 10^45
```
The program needs to be able to handle input going up to Centillion, which is 10^303. A list of names and their standard form values can be found [here](http://polytope.net/hedrondude/illion.htm) - note that this gives values for every 10^3 increment up to 10^63, but then gives them in 10^30 increments, however the pattern is fairly straightforward.
The program needs to handle all 100 cases (even the ones not explicitly given by the website provided) - here are some examples of this:
```
"sexvigintillion" -> 10^81
"unnonagintillion" -> 10^276
"octotrigintillion" -> 10^117
```
Input can be given via STDIN, function argument or hard-coded as a string.
This is code-golf, so shortest code wins!

[Answer]
# Python 2 (~~384~~ ~~368~~ ~~365~~ ~~348~~ 347 bytes)
```
def c(s):
 s=s[:-6].replace('int','');k=0;d=dict(un=1,doe=2,tre=3,quattuor=4,quin=5,sex=6,septen=7,octo=8,novem=9,b=3,tr=4,quadr=5,qu=6,sext=7,sept=8,oct=9,non=10,dec=11,vig=21,trig=31,quadrag=41,quinquag=51,sexag=61,septuag=71,octog=81,nonag=91,cent=101)
 for p in(s!='m')*list(d)*2:
    if s.endswith(p):s=s[:-len(p)];k+=3*d[p]
 return 10**(k or 6)
```
(The `if` line is indented with a single tab, and the rest with single spaces.)
Here `c('million') == 10**6` has to be a special case because `'novem'` also ends in `'m'`.
Examples:
```
c('million') == 10**6
c('trillion') == 10**12
c('quattuordecillion') == 10**45
c('novemnonagintillion') == 10**300
c('centillion') == 10**303
```
Thanks to Falko for obfuscating it down to 350 bytes.
---
For practice I tried rewriting this as a one-liner using lambdas. It's ~~404~~ ~~398~~ ~~390~~ ~~384~~ ~~380~~ 379 bytes:
```
c=lambda s:(lambda t=[s[:-5].replace('gint',''),0],**d:([t.__setslice__(0,2,[t[0][:-len(p)],t[1]+3*d[p]])for p in 2*list(d)if t[0].endswith(p)],10**t[1])[1])(un=1,doe=2,tre=3,quattuor=4,quin=5,sex=6,septen=7,octo=8,novem=9,mi=2,bi=3,tri=4,quadri=5,qui=6,sexti=7,septi=8,octi=9,noni=10,deci=11,vii=21,trii=31,quadrai=41,quinquai=51,sexai=61,septuai=71,octoi=81,nonai=91,centi=101)
```
[Answer]
## JS (ES6), ~~292~~ 270
Understands only the numbers written in the given list. The OP isn't clear about the others.
```
z=b=>{a="M0B0Tr0Quadr0Quint0Sext0Sept0Oct0Non0Dec0Undec0Doedec0Tredec0Quattuordec0Quindec0Sexdec0Septendec0Octodec0Novemdec0Vigint0Trigint0Quadragint0Quinquagint0Sexagint0Septuagint0Octogint0Nonagint0Cent".split(0);for(i in a)if(~b.indexOf(a[i]))return"10^"+(20>i?3*i+6:93+30*(i-20))}
```
Example:
```
z("Billion") // "10^9"
z("Centillion") // "10^303"
```
[Answer]
# C, 235
Handles all 100 cases.
Program uses stdin and stdout.
Who needs regexes for camel-case splitting?
```
char*Z="UUUi+W<)E(<7-7-++*)('&%$,*$&%$",u[999]="\0MBRilDriPtiNiUnOeReTtUiXTeCtVeCiGRigRaUagInquiXaXsexPtuOgOoNaCeCeK1",s[99],*U=u+67;
main(n){
for(gets(s);*--U;)
*U<95?
*U|=32,
n+=!!strstr(s,U)*(*Z++-35),
*U=0:
3;puts(memset(u+68,48,3*n)-1);
}
```
### Example
```
octoseptuagintillion
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
```
[Answer]
# Clojure, 381 377 bytes
```
(defn c[x](let[l{"M"6"B"9"Tr"12"Quadr"15"Quint"18"Sext"21"Sept"24"Oct"27"Non"30"Dec"33"Undec"36"Doedec"39"Tredec"42"Quattuordec"45"Quindec"48"Sexdec"51"Septendec"54"Octodec"57"Novemdec"60"Vigint"63"Trigint"93"Googol"100"Quadragint"123"Quinquagint"153"Sexagint"183"Septuagint"213"Octogint"243"Nonagint"273"Cent"303}v(l(clojure.string/replace x #"illion$" ""))](Math/pow 10 v)))
```
Example:
`(c "Septuagintillion") ;; 1.0E213`
[Answer]
# Haskell, 204 bytes (+9 for formatted String)
```
import Data.List
x s=10^(f$[a|k<-tails s,i<-inits k,(b,a)<-zip["ce","ad","un","do","b","mi","vi","tr","at","ui","x","p","oc","no","ec","g"]$100:4:1:2:2:[1..],b==i])
f[]=3
f(x:11:r)=30*x+f r
f(x:r)=3*x+f r
```
In GHCi:
```
*Main> x "decillion"
1000000000000000000000000000000000
```
Replacing `10^(` with `"10^"++(show.` adds another 9 bytes:
```
import Data.List
x s="10^"++(show.f$[a|k<-tails s,i<-inits k,(b,a)<-zip["ce","ad","un","do","b","mi","vi","tr","at","ui","x","p","oc","no","ec","g"]$100:4:1:2:2:[1..],b==i])
f[]=3
f(x:11:r)=30*x+f r
f(x:r)=3*x+f r
```
In GHCi:
```
*Main> x "decillion"
"10^33"
```
**Edit:** I had to correct for `"quinquagintillion"` which contains `"qua"`.
]


[Question]
      [
Quite a few people here are probably avid XKCD readers. So, I figure I'd challenge you guys to do something that Megan can do easily: make a script that generates thousands of reassuring parables about what computers can never do.
[![XKCD #1263](https://i.stack.imgur.com/NtDma.png "'At least humans are better at quietly amusing ourselves, oblivious to our pending obsolescence' thought the human, as a nearby Dell Inspiron contentedly displayed the same bouncing geometric shape screensaver it had been running for years.")](http://xkcd.com/1263/)
Your script
* Can be written in any language
* Must be code-golfed
* Must take an input (on `stdin` or your language equivalent) on the number of parables it will spit out (you can assume this will not exceed `MAX_INT` or equivalent).
* Will output a number of **randomly** generated parables.
The parables are as follows
* Starts with `'Computers will never '`
* Next, one of 16 unique English verbs which you can choose freely to optimize your program, but *must* include `code-golf` and `understand`.
* Next, one of 16 unique English nouns which again, you can choose freely to optimize your program, but *must* include `a salad` and `an octopus`.
* Next, one of 16 unique English clauses which you can choose freely to optimize your program, but *must* include `for fun` and `after lunch`.
* Ends with a newline (`\n` or equivalent) character
So, for example, if the input is `2`, a valid output would be
```
Computers will never code-golf a salad for lunch
Computers will never hug a tree in vain
```
Program size is counted in bytes, not characters (so no unicode gibberish). [Standard loopholes](https://codegolf.meta.stackexchange.com/questions/1061/standard-loopholes-which-are-no-longer-funny "Standard loopholes") are not allowed.
This is my first challenge, so if I should make some obvious changes, please comment.
**Edit:** I am contemplating to substract the dictionary size from the byte count, to encourage dictionary 'compression'. I will see from future answers if this is remotely feasible ; if it is, you can count on a bonus.

[Answer]
Here's a slightly different approach:
# Python, 368 308 297 bytes
EDIT, I actually golfed it this time. Shaved off 60 characters.
```
from random import*
from en import*
C=choice
v=["code-golf","understand","go","do"]
n=["salad","octopus","fun","lunch"]
for f,l in("verbs",v),("nouns",n):exec"l.append(str(C(wordnet.all_"+f+"()))[:-4]);"*12
exec'print"Computers will never",C(v),noun.article(C(n)),C(("for","after")),C(n);'*input()
```
Here is the golf-trick that I'm most proud of:
```
for f,l in("all_verbs",v),("all_nouns",n):
```
I didn't even know python could do that! Here's a simpler explanation:
```
for (a, b) in ((0, 1), (1, 2), (2, 3)):
```
assigns a and b to 0 and 1, and then to 1 and 2, and then to 2 and 3.
---
This uses NodeBox's linguistics library to generate a list of verbs/nouns/clauses, and then randomly selects from them.
This library is not that great for generating random words (hence the 368 bytes), but the nice thing about this approach is you get some pretty random reassuring parables with it. Here is what I mean.
```
Computers will never attempt a syria for synchronization.
Computers will never understand a salad for change of mind.
Computers will never brim an electric company for synchronization.
Computers will never pivot a dusk for fun.
Computers will never bedaze an electric company for genus osmerus.
Computers will never brim a salad for vital principle.
Computers will never attempt an erythroxylum after lunch.
Computers will never understand an uuq for water birch.
Computers will never brim an ictiobus for change of mind.
Computers will never brim an ictiobus for 17.
Computers will never lie in an octopus for change of mind.
Computers will never happen upon a toothpowder for water birch.
Computers will never typeset an electric company for change of mind.
Computers will never brim a french oceania after lunch.
Computers will never bring out an ictiobus for glossodia.
Computers will never bedazzle an animal fancier for ash cake.
Computers will never attempt a dusk for genus osmerus.
Computers will never understand an animal fancier for genus osmerus.
Computers will never accredit a prickly pear cactus for 17.
Computers will never typeset an erythroxylum for water birch.
```
But hey, I don't think anybody else's program will generate the saying: "Computers will never bedazzle an animal fancier for ash cake."
Here's an ungolfed version (574 bytes):
```
import random
import en
v = ["code-golf", "understand"]#list of verbs
n = ["a salad", "an octopus"]#list of nouns
c = ["for fun", "after lunch"]#list of clauses
for i in range(14):
    v.append(str(random.choice(en.wordnet.all_verbs()))[:-4])
    n.append(en.noun.article(str(random.choice(en.wordnet.all_nouns()))[:-4]))
    c.append("for "+str(random.choice(en.wordnet.all_verbs()))[:-4])
N=input("Enter the number of reassuring phrases you want: ")
for i in range(N):
    print "Computers will never"+' '+random.choice(v)+' '+random.choice(n)+' '+random.choice(c )+'.'
```
And lastly but definitely not leastly, here are some of my favorite reassuring parables, that I predict will become really popular catch-phrases in the next 10-15 years.
```
Computers will never move around a methenamine for godwin austen.
Computers will never conk an adzuki bean for bitterwood tree.
Computers will never jaywalk a cross-dresser for fun.
Computers will never hyperbolize an accessory after the fact for norfolk island pine.
Computers will never dissolve a salad for earth wax.
Computers will never acetylise an incontrovertibility for dictatorship.
Computers will never reciprocate a strizostedion vitreum glaucum for commelinaceae.
Computers will never goose an action replay for star chamber.
Computers will never veto a bottom lurkers for jackboot.
Computers will never reciprocate a visual cortex for oleaginousness.
Computers will never baptise a special relativity after lunch.
Computers will never understand a gipsywort for citrus tangelo.
Computers will never get it a brand-name drug for electronic computer.
Computers will never deforest a paperboy after lunch.
Computers will never bundle up a nazi for repurchase.
Computers will never elapse a bernhard riemann for counterproposal.
```
and my personal favorite:
```
Computers will never romanticise a cockatoo parrot for cross-fertilization.
```
[Answer]
## CJam, ~~238~~ 232 (or 209) bytes
```
ri{'C"!fmQ$h/q6fW*LC*hBd11(kA>.TfqJ0++#<>A]XThJkY b~os;vMg_D-}zYX%_,PozNxe5_8`}$H;2IUZ]&$c+m~HJ*|!n\A^:W-*O\"V-/8Kg ,_b(N#M/1Zh6*%\#t22'#|\"BJN=Za2_.R"32f-96b28b" -"'{,W%+f=)/(\[G/~["for ""after "]\m*\(a\"a "f{\+}+\]{mr0=}%S*N}*
```
This uses many verbs/nouns/clauses from already posted answers but some are new too. I have base converted the characters to shave off some extra bytes.
The base converted string can be golfed 24 more bytes (to get a [209 byte solution](https://mothereff.in/byte-counter#ri%7B%27C%229%C3%B3%C3%9F%C3%82%2F%C3%83%C2%87C%20e%C2%98G%3Fdc%C3%85o%C3%B8%C2%A3gaC%23Y%C3%A4%C2%A9%C3%8F%C2%A1%C3%A1q%C2%B6hm%C2%90%29%C3%B0%C2%ADa%C2%81%C3%A2%25%C3%98No%3D%C2%85%C3%B3%C3%8Frb%C2%8C%C3%81z%C2%B4%C2%BE%C2%9D%3Bq%C2%B7u%C2%AC%C2%87%26%C3%B1*%C2%B1%C3%A4%C3%B4%C2%A9%406W%C2%B1U%C2%B9%C2%A5%C2%A2%29%C3%82%C2%B7%C2%AB%C3%85x%C2%B6%C3%B3V%C2%8A%C2%93%C2%AC%C2%9C%C2%ACdhj%C2%82a%C2%92%C2%BC%20%C2%AA%5C%22r%5B%C3%A7%C3%8B74%C3%84%C2%93%C2%85%C3%A3%C3%90%C2%B3%C3%AE%2C%C3%B33g%C3%88%24A%C3%AFL%2232f-222b28b%22%20-%22%27%7B%2CW%25%2Bf%3D%29%2F%28%5C%5BG%2F~%5B%22for%20%22%22after%20%22%5D%5Cm*%5C%28a%5C%22a%20%22f%7B%5C%2B%7D%2B%5C%5D%7Bmr0%3D%7D%25S*N%7D*); Note that you have to consider the character count instead of byte count as all characters have an ASCII code of less than 255 but the site still consider some has unicode) but I wanted the string to consist only printable ASCII characters.
Just for reference, here is the 209 bytes version:
```
ri{'C"9óßÂ/ÃC eG?dcÅoø£gaC#Yä©Ï¡áq¶hm)ðaâ%ØNo=óÏrbÁz´¾;q·u¬&ñ*±äô©@6W±U¹¥¢)Â·«Åx¶óV¬¬dhja¼ ª\"r[çË74ÄãÐ³î,ó3gÈ$AïL"32f-222b28b" -"'{,W%+f=)/(\[G/~["for ""after "]\m*\(a\"a "f{\+}+\]{mr0=}%S*N}*
```
Takes the number of lines to print from STDIN like:
```
12
```
Output:
```
Computers will never code-golf an octopus for fun
Computers will never code-golf a bag after za
Computers will never eat a hem after tip
Computers will never eat an octopus for tip
Computers will never get a fax for you
Computers will never dry a gym for za
Computers will never get a guy for tip
Computers will never do a pen for fun
Computers will never see a bar after you
Computers will never tax a pen for ex
Computers will never get a hem for lunch
Computers will never win a pen for ex
```
[Try it online here](http://cjam.aditsu.net/)
[Answer]
# JavaScript ES6, 331 336 bytes
```
n=prompt(a='')
r=s=>s+Math.random()*16>>0
p=q=>'OctopusSaladCutCueBatJamKidPenDogFanHemDotTaxSowDyeDigCode-golfUnderstandLunchFunMeYouUsItAdsPaZaMenTwoIceJamWarRumWax'.match(/[A-Z][^A-Z]+/g)[q].toLowerCase()
while(n-->0)y=r(0),z=r(18),a+=`Computers will never ${p(r(2))} a${y?'':'n'} ${p(y)} ${z<18?'afte':'fo'}r ${p(z)}
`
alert(a)
```
```
n=prompt()
a=''
function r(s){return s+Math.random()*16>>0}
function p(q){return' '+'OctopusSaladCutCueBatJamKidPenDogFanHemDotTaxSowDyeDigCode-golf\
UnderstandLunchFunMeYouUsItAds\
PaZaMenTwoIceJamWarRumWax'.match(/[A-Z][^A-Z]+/g)[q].toLowerCase()}
while(n-->0)
  y=r(0),z=r(18),
  a+='Computers will never'+p(r(2))+(y?' a':' an')+p(y)+(z<18?' after':' for')+p(z)+'\n'
alert(a)
```
I picked words that work as both verbs and nouns to shorten the list, but let me know if that is not allowed. Try it out above using Stack Snippets (The code there has been formatted to use ES5) or at <http://jsfiddle.net/5eq4knp3/2/>. Here is an example output:
```
Computers will never hem a cut for ads
Computers will never dot a pen after lunch
Computers will never code-golf a bat for free
Computers will never sow a dog for me
Computers will never cut an octopus for fun
```
[Answer]
# Python - ~~390 385~~ 383
```
from pylab import*
S=str.split
n=input()
while n:n-=1;i,j,k=randint(0,16,3);print"Computers will never",S("buy cut dry eat fax get pay rob see sue tax tow wax win code-golf understand")[i],"a"+"n"*(j<1),S("octopus salad bag bar bee bow boy bra dad fax gym guy hat man mom pet")[j],"for "*(k>2)+S("after lunch,naked,ever,fun,me,you,us,tip,gas,cash,air,oil,beer,love,food,dope",",")[k]
```
Random example output:
```
Computers will never pay an octopus for oil
Computers will never cut a bra for beer
Computers will never eat a bee for us
Computers will never rob a pet for you
Computers will never tax a pet for tip
Computers will never buy a salad for cash
Computers will never sue a boy naked
Computers will never see a bar for you
Computers will never wax a bra for beer
Computers will never sue an octopus for us
```
[Answer]
# Perl - 366
```
@w="Code-golfUnderstandBeDoTieSeeSawEatCutCapSitSetHateZapSipLoveSaladOctopusSeaBeeCatDogHatBatJobManLapCapRapMapDotAnt0fun1that1noon1work0good0sure0reason0nothing0you1you1lunch1all0me0nowToday1me"=~s/\d/("For ","After ")[$&]/reg=~/([A-Z][^A-Z]+)/g;print"Computers will never ".lc"$w[rand 16] a".$w[16+rand 16]=~s/^[AO]?/(n)[!$&]." $&"/re." $w[32+rand 16]
"for 1..<>
```
Here is a test:
```
$ perl ./parables.pl <<<3
Computers will never do an ant after noon
Computers will never do a lap after all
Computers will never love an octopus for sure
```
[Answer]
## CJam, ~~353~~ ~~317~~ 301 bytes
I'm using Falko's word list, for fairness, so that the only difference in golfing is due to the languages and not the content (I might change the word list if people start golfing the content as well).
```
"Computers will never ""buy
cut
dry
eat
fax
get
pay
rob
see
sue
tax
tow
wax
win
code-golf
understand"N/[" an octopus"" a ""salad
bag
bar
bee
bow
boy
bra
dad
fax
gym
guy
hat
man
mom
pet"{N/\f{\+}~]}:F~S["after lunch""naked""ever""for ""fun
me
you
us
tip
gas
cash
air
oil
beer
love
food
dope"Fm*m*m*mr0=
```
[Answer]
## NetLogo, 396
I also used Falko's word list, with two exceptions (which don't change the length of program).
```
to f let a["after lunch""ever""alone"]type(word"Computers will never "one-of["buy""cut""dry""eat""fax""get""pay""rob""see""sue""tax""tow""wax""win""code-golf""understand"]" a"one-of["n ocotpus"" salad"" bag"" bar"" bee"" bow"" boy"" bun"" dad"" fax"" gym"" guy"" hat"" man"" mom"" pet"]" "one-of fput word"for "one-of["fun""me""you""us""tip""gas""cash""air""oil""beer""love""food""dope"]a"\n")end
```
Depending on how you define "program", you can remove the first five and last three characters, thus a score of 388.
]


[Question]
      [
Write the shortest function that returns the content of the first result of a Google search ("I'm feeling lucky").
Example:
```
lucky('cat');
```
Might return something like:
```
<!DOCTYPE html>
<html>
  <head>
    <title>Cats are cool</title>
    <meta charset="utf-8" />
  </head>
  <body>
    <h1>CAAAAAAAAAAATSSSSSSSSSS!!!!!!!!</h1>
    <p>
      Cats are so cool!
    </p>
  </body>
</html>
```

[Answer]
# Bash, 46 bytes
```
l()(wget -UM -qO- "gogle.de/search?btnI&q=$1")
```
Uses the actual *I'm feeling lucky* feature, just like the other answers.
Gogle blacklists some user agents (including WGet's, cURL's and Java's), but **M** seems to work just fine.
[Answer]
# Ruby, 79 / 145
I borrowed the `btnI` trick from @rink.attendant.6 for this solution. Thanks Beta Decay for shortening it by 2 characters.
```
require'open-uri'
f=->q{URI(URI.escape"http://gogle.de/search?btnI&q="+q).read}
```
I also have a solution which actually gets the first result from the results page, which is 145 bytes.
```
require'open-uri'
f=->q{open(URI.extract(URI(URI.escape"http://google.com/search?q=#{q}").read.split('class="r"')[1])[0].split("&")[0]).read}
```
[Answer]
## PHP, ~~157~~ ~~105/87~~ ~~102/87~~ 100/85
### Using [`file_get_contents`](https://php.net/manual/en/function.file-get-contents.php)
```
<?php function l($q){return file_get_contents("https://google.ca/search?btnI&q=".rawurlencode($q));}
```
Without allowing for spaces in the search term it's only 87 characters:
```
<?php function l($q){return file_get_contents("https://google.ca/search?q=$q&btnI");}
```
### Original versions using [cURL](https://php.net/manual/en/book.curl.php)
I suppose that short array syntax can be used on PHP 5.4+:
```
<?php function l($q){$ch=curl_init("https://google.ca/search?btnI=1&q=".rawurlencode($q));curl_setopt_array($ch,[19913=>1,52=>1]);return curl_exec($ch);}
```
Otherwise it's five more characters with the normal array initializer, 162:
```
<?php function l($q){$ch=curl_init("https://google.ca/search?btnI=1&q=".rawurlencode($q));curl_setopt_array($ch,[19913=>1,52=>1]);return curl_exec($ch);}
```
Version that **does not allow spaces in the search term**: No need for URL encoding (138):
```
<?php function l($q){$ch=curl_init("https://google.ca/search?q=$q&btnI=1");curl_setopt_array($ch,[19913=>1,52=>1]);return curl_exec($ch);}
```
Ungolfed using constants
```
<?php
function l($q){
$ch = curl_init("https://google.ca/search?btnI=1&q=" . rawurlencode($q));
curl_setopt_array($ch, array(
  CURLOPT_RETURNTRANSFER => 1,
  CURLOPT_FOLLOWLOCATION => 1
  ));
return curl_exec($ch);
}
```
[Answer]
## C#, ~~183~~ ~~180~~ 178
This is my first time ever writing code in C# so it could probably use improvement. Feedback is welcome!
```
string l(string q){return System.Text.Encoding.UTF8.GetString((new System.Net.WebClient()).DownloadData("https://google.ca/search?btnI&q="+System.Web.HttpUtility.UrlEncode(q)));}
```
### Unminified
```
string l(string q) {
    return System.Text.Encoding.UTF8.GetString(
        (new System.Net.WebClient()).DownloadData(
            "https://google.ca/search?btnI&q=" + System.Web.HttpUtility.UrlEncode(q)
        )
    );
}
```
[Answer]
## CJam, 40 bytes
Thought, I'll finally give the `g` method a try
```
{"gogle.de/search?btnI&q="\S/"%20"*+g}:F
```
This creates a method/block `F` which can be used like
```
{"gogle.de/search?btnI&q="\S/"%20"*+g}:F; "cats and dogs"F
```
This is how functions work in CJam ..
Doesn't work in online interpreter, so you will have to [download and use](http://sourceforge.net/p/cjam/wiki/Home/) the Java one.
Note that Google denies all requests with Java user agent, so you will have to start CJam with an additional flag `-Dhttp.agent=M`
[Answer]
# Python 3 - 78
Uses `gogle.de` for brevity. Run as `f(query)`.
```
f=lambda x:__import__("requests").get("http://gogle.de/search?btnI&q="+x).text
```
If you want to have spaces in your query it's 98 characters.
```
f=lambda x:__import__("requests").get("http://gogle.de/search?btnI&q="+x.replace(" "," %20")).text
```
]


[Question]
      [
Your favourite programming language has just had a birthday. Be nice and sing it the **Happy Birthday** song.
Of course you should accomplish this by writing a program in that language.
The program takes no input, and writes the following text to the standard output or an arbitrary file:
```
Happy Birthday to You
Happy Birthday to You
Happy Birthday Dear [your favourite programming language]
Happy Birthday to You
```
You should substitute the bracketed part (and omit the brackets).
This is a code golf — shortest code wins.
## UPDATE
I'm glad that the question aroused great interest. Let me add some extra info about scoring. As stated originally, this question is a code golf, so the shortest code is going to win. The winner will be picked at the end of this week (19th October).
However, I'm also rewarding other witty submissions with up-votes (and I encourage everybody to do so as well). Therefore although this is a code-golf contest, not-so-short answers are also welcome.
## Results
Congratulations to [Optimizer](https://codegolf.stackexchange.com/users/31414/optimizer), the winner of this contest with his 42 byte long, CJam [submission](https://codegolf.stackexchange.com/a/39754/40695).
## Leaderboard
Here is a Stack Snippet to generate both a regular leaderboard and an overview of winners by language.
```
/* Configuration */
var QUESTION_ID = 39752; // Obtain this from the url
// It will be like https://XYZ.stackexchange.com/questions/QUESTION_ID/... on any question page
var ANSWER_FILTER = "!t)IWYnsLAZle2tQ3KqrVveCRJfxcRLe";
var COMMENT_FILTER = "!)Q2B_A2kjfAiU78X(md6BoYk";
var OVERRIDE_USER = 48934; // This should be the user ID of the challenge author.
/* App */
var answers = [], answers_hash, answer_ids, answer_page = 1, more_answers = true, comment_page;
function answersUrl(index) {
  return "https://api.stackexchange.com/2.2/questions/" +  QUESTION_ID + "/answers?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + ANSWER_FILTER;
}
function commentUrl(index, answers) {
  return "https://api.stackexchange.com/2.2/answers/" + answers.join(';') + "/comments?page=" + index + "&pagesize=100&order=desc&sort=creation&site=codegolf&filter=" + COMMENT_FILTER;
}
function getAnswers() {
  jQuery.ajax({
    url: answersUrl(answer_page++),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      answers.push.apply(answers, data.items);
      answers_hash = [];
      answer_ids = [];
      data.items.forEach(function(a) {
        a.comments = [];
        var id = +a.share_link.match(/\d+/);
        answer_ids.push(id);
        answers_hash[id] = a;
      });
      if (!data.has_more) more_answers = false;
      comment_page = 1;
      getComments();
    }
  });
}
function getComments() {
  jQuery.ajax({
    url: commentUrl(comment_page++, answer_ids),
    method: "get",
    dataType: "jsonp",
    crossDomain: true,
    success: function (data) {
      data.items.forEach(function(c) {
        if (c.owner.user_id === OVERRIDE_USER)
          answers_hash[c.post_id].comments.push(c);
      });
      if (data.has_more) getComments();
      else if (more_answers) getAnswers();
      else process();
    }
  });
}
getAnswers();
var SCORE_REG = /<h\d>\s*([^\n,]*[^\s,]),.*?(\d+)(?=[^\n\d<>]*(?:<(?:s>[^\n<>]*<\/s>|[^\n<>]+>)[^\n\d<>]*)*<\/h\d>)/;
var OVERRIDE_REG = /^Override\s*header:\s*/i;
function getAuthorName(a) {
  return a.owner.display_name;
}
function process() {
  var valid = [];

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

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

  });

  valid.sort(function (a, b) {
    var aB = a.size,
        bB = b.size;
    return aB - bB
  });
  var languages = {};
  var place = 1;
  var lastSize = null;
  var lastPlace = 1;
  valid.forEach(function (a) {
    if (a.size != lastSize)
      lastPlace = place;
    lastSize = a.size;
    ++place;

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

    languages[lang] = languages[lang] || {lang: a.language, user: a.user, size: a.size, link: a.link};
  });
  var langs = [];
  for (var lang in languages)
    if (languages.hasOwnProperty(lang))
      langs.push(languages[lang]);
  langs.sort(function (a, b) {
    if (a.lang > b.lang) return 1;
    if (a.lang < b.lang) return -1;
    return 0;
  });
  for (var i = 0; i < langs.length; ++i)
  {
    var language = jQuery("#language-template").html();
    var lang = langs[i];
    language = language.replace("{{LANGUAGE}}", lang.lang)
                       .replace("{{NAME}}", lang.user)
                       .replace("{{SIZE}}", lang.size)
                       .replace("{{LINK}}", lang.link);
    language = jQuery(language);
    jQuery("#languages").append(language);
  }
}
```
```
body { text-align: left !important}
#answer-list {
  padding: 10px;
  width: 290px;
  float: left;
}
#language-list {
  padding: 10px;
  width: 290px;
  float: left;
}
table thead {
  font-weight: bold;
}
table td {
  padding: 5px;
}
```
```
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">
<div id="answer-list">
  <h2>Leaderboard</h2>
  <table class="answer-list">
    <thead>
      <tr><td></td><td>Author</td><td>Language</td><td>Size</td></tr>
    </thead>
    <tbody id="answers">
    </tbody>
  </table>
</div>
<div id="language-list">
  <h2>Winners by Language</h2>
  <table class="language-list">
    <thead>
      <tr><td>Language</td><td>User</td><td>Score</td></tr>
    </thead>
    <tbody id="languages">
    </tbody>
  </table>
</div>
<table style="display: none">
  <tbody id="answer-template">
    <tr><td>{{PLACE}}</td><td>{{NAME}}</td><td>{{LANGUAGE}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
<table style="display: none">
  <tbody id="language-template">
    <tr><td>{{LANGUAGE}}</td><td>{{NAME}}</td><td>{{SIZE}}</td><td><a href="{{LINK}}">Link</a></td></tr>
  </tbody>
</table>
```

[Answer]
# [Quipu](https://esolangs.org/wiki/Quipu), ~~123~~ 115 bytes
```
'H'D't[][][]
'a'e'o/\/\/\
'p'a' 2&1&2&
'p'r'Y[][][]
'y' 'o/\/\/\
' 'Q'u
'B'u\n
'i'i/\
'r'p
't'u
'h\n
'd
'a
'y
'
/\
```
[Try it online!](https://tio.run/##zVltc9s2Ev7OX7FhpyYZJ5Kdj6rlXu1cp@21Se7SmZsb272BKUhiQ5EsANrRaPTbc7sLgCb1Ykt2PHOjSSwCD/bl2cUSWOlU5OJLv/9BaCNhXtYK0nIkISvATKX9rmVqsrIAUYx4MCuq2niEfXCQHrwt81wo0Nmk0DAVNxJMCdcSpE5FJUdwm5kpjFqgIJtVpUJxZe8jak@lH0gR5KTOaiOuc9n7QSkxP6vHY6mC8vpPnIXfBNohPxtZjDT8UFULo@aLnwsjVaUk/h9/EErjn0Z8b6zK2dncSB1/6FWqnPQm0vBzkiTLVJh0ukiFllDJgV3798@prMiO4WmlssLkRRzaGZBKlWoA4WElScxvUmsxkUnAAjI5gJYljRgYnkIjqAVopMEhrl2X918SN5Kf39fm/fisrNHjzTLflS4q4wxJC5PlMkhzoTWs@BPPrPwBfDS4dpI0RK5BEs@3FbEw80rC71MlxQiG0IrLxT@K0lwFIzkGUVX5PNbMOqrgv8nAgi/s/wy@QgmL4AYTwrBAPYBfM20ukBqaepfl0O9DrTF7MJeykSyMZrg2yir1Qq0bV96iOGEYstKFOcFtjJK6zs2g44l176rrH@KtRxSfX7NCahiXiEunsIAcw4DicshxAl2Wf12cT4UiEbkzBeOHT0dBNobYuQtDdjJBEmiU1vZyWUxwo5zCERwcsLj4KIEXQwgvwxC/Evh2iuGF2Mo8gda65L7JRiDPJb1M/3uaYfpXAsPjLDwcwjEbYx9Rb1s6RysHg44U8talARJjaB2NvKtnFFm0M7DE0oQJGn99oGFwaBUGjdo3mKxNXD31PUzk3NPV@BiGy6CJ7f3Q18dLlOtHUVmWtgOXYdh8aBwozhLrpM9x6wgNrwfJWQ/HRE2LW5hROcEx3r/RRUT5MapnlbUZlXjzUe6ru3zmJ6s5cVYTN/@SY6I1aK9Cy14fB@2VOBKGTuMfT9T4UeZ7qkwHQCkPSFKKqfU2m2SGbLhjxfLUZeaA7bQJ11ZEmnhfdNUfBcvuEJqa9kxp9z9@wR3uJP/tPslrYh8SCi/h@MhJ/vbr28zivfxvHiF/FYwb92gDtvPILu1qGyGteZcR2dfJIFq2EmcPvoweToJio8DosogcwGwBGA/oPzHdfy52TXbPwuETNVK1fF9xsYw/v4J5Qh4SO/Nkj23@@nmseL2fFS@fx4qX@1nR3yHTXDo@3lQ8gu1ZifvPQ05/V3KWnar11e34dr8gDb@CFee/zLwd1oYhFbt9rPj@iVY4A/bQeLJDcp48Bzcne1LzLAE62T1APl1PdyDs9DlsPf1/IOx0f8K@e5Qdu/s5eKKfP4l839L5zRNVnlfzPTXCozSuS1vXuHQfd4dM81JLvDnh/Za0gchzuLYqt99WIPPXzA2Xk32NXrIgQVenLVdzykx7VbZa/KXKXe222ccird@NdXiSZEmoVUlTq8IqxsdKZTfCSKC@QccFbqGg8b5H4S0frDcd/AU6o2OvPSN395e/lmaJOytrvlGH60jUxUiduHjZ/smmbs5jmijtps@i1SuhbtumKCQOhUSW@Y38BQmKCwQW84T5oSh1i6LlDSwdJ9zGa27vWFoy11Gi7@h5ecteb3SPukm6Rsme98uQGlQF/gsvw15oU0hBZRTfQuj7FDe5pLxs6eXXs29LvLAI9ItaO@WNbHo/3bym9TFKTly/R6SfXHMIfb9qbuvUG@m47yNdsLcFDAbUYbFzd7Hl24Sfs158whnff2LuGx2YuzTaM8L2o/SnrNLcAdV4SeaFLOFPDA77Pha5ljw0zopMT3mQ5d/DCDVnXjR4erDy2kyxjMBKmhJPHdddk8CXCIVpM7TMrbH0QJIw@VnyELkbWfXvoydkWGNzK9F4jCvKmOLGjxyRTZZ5cNFAN5rqUHoV5VofHQzrw1JgVsDuFbOGJfO7SHd2HrOJgVFzZDW22GMu0nbVCuWxcHXwmv92DB8XscCJVUVucAf631dSCVNSE/SvOsMaA@aWOshGTrAEv4JJaWxTWlAo@FcAerrm2ghp2055f4s6eDgTDMiirCdTfDNM6hm1eunFAiXbSL8FcB5Y0v1xqUqaFyKukqbFftANHafKvZvBtVwqTHyqus1uNqqWga1x7SpsFSZ7pfu5KCJjKz5XC0AEvkLp9WdKy3STBl6wc3UvP3e1nRXY1oeXrxl8XhaIlj3aldTqphYvJ@ydMuWaQ03urScEbsprqX4sFdLd@b2iJaW13m0Te8EmmLeCf96I75hhnD9OErB567C/S1shm5rLlLQqceymbe/dHQhcteXC27yibEKgkXj3IHynTi6CFbUgsezjsOXbLeMzBCu4k3r36nqgPlOR7Z5eeLY5EnnA2qGFPuIa6RV45rAnGD4I20YtP3uhGPRautrizy@rWC/fYVePO6vwptINIOba5QvXvUruNrVdxivOSkwAUWxa5U5U/q23FeA30FaA2wBb531GbgU0qbgV0bxStiL8e6QD8L@8LegISL9YDpW4DcPwS/RT9DYyF1f0CSIRyajsX9IniCp8hDcHxwdvDuhBRf/xsDnebhoYRP@M6iA6i@rLIoiyKKNBFVVBZGh8SqMjFI3LEBz0L7@g3uWX/wE "Scala – Try It Online")
### Explanation
Each pair of columns in a Quipu program is a "thread." Execution proceeds from the top of each thread to the bottom, left to right from one thread to the next. Each thread also stores a value, which can be referenced by other threads.
* Thread 0 outputs `Happy Birthday`  with a trailing space and sets its value to that string.
* Thread 1 sets its value to `Dear Quipu` with a trailing newline.
* Thread 2 outputs `to You` with a trailing newline and sets its value to that string.
* Thread 3 outputs the value of thread 0, then outputs the value of thread 2.
* Thread 4 outputs the value of thread 0, then outputs the value of thread 1.
* Thread 5 outputs the value of thread 0, then outputs the value of thread 2.
[Answer]
# [tinylisp](https://github.com/dloscutoff/Esolangs/tree/master/tinylisp), ~~120~~ 114 bytes
```
(load library
(d x(q(Happy Birthday
(d y(join(concat x(q(to You)))spc
y
y
(join(concat x(q(Dear tinylisp)))spc
y
```
[Try it online!](https://tio.run/##Vc1BCoMwEIXhvad4y8k1xEWv0OU0KXQkZNI4gnP6qFiEbh8f7zcpnmWpvVNWTsjyatx8oISNvqAH1@oYpdknsePcnWaVAopaItvFTPHUNYSApcbhcMfDqf7Q9OYG@wVv2/sO "tinylisp – Try It Online")
[Answer]
# [Jelly](//github.com/DennisMitchell/jelly), 31 [bytes](//github.com/DennisMitchell/jelly/wiki/Code-page)
```
“Ñƒẉ%VİỊ½żƒ»µ,;“©ʋ⁶ẓsŀKɗʠØ»,⁸¤Y
```
[Try it online!](//jelly.tryitonline.net#code=4oCcw5HGkuG6iSVWxLDhu4rCvcW8xpLCu8K1LDvigJzCqcqL4oG24bqTc8WAS8mXyqDDmMK7LOKBuMKkWQ)
[Answer]
## [Golisp](https://github.com/tuxcrafting/golisp), ~~102~~ 100 bytes
EDIT: Removed 2 bytes by changing the last `writeln` to `write`
```
write@*["Happy Birthday to You\n"2]writeln@"Happy Birthday Dear Golisp"write@"Happy Birthday to You"
```
Ungolfed & commented version:
```
write @ *["Happy Birthday to You\n" 2] # Call write with "Happy Birthday to You\n" repeated 2 times (f@x == f[x]) #
writeln @ "Happy Birthday Dear Golisp" # Write "Happy Birthday Dear Golisp" to stdout #
write @ "Happy Birthday to You" # Write "Happy Birthday to You" to stdout #
```
[Answer]
# [beeswax](http://esolangs.org/wiki/Beeswax), 66 chars
I created beeswax in December 2015. This solution is just for fun.
```
>`y Dear beeswax`5Np
pb"M`adhtriB yppaH`<3~4_
>`y To You`N~L;~   d
```
You can clone the beeswax interpreter, language specifications and instructions from [my GitHub repository](https://www.github.com/m-lohmann/BeeswaxEsolang.jl).
[Answer]
# [Zsh](https://www.zsh.org/), 51 bytes
```
set Happy\ Birthday to You
<<.
$@
$@
$1 Dear zsh
$@
```
[Attempt This Online!](https://ato.pxeger.com/run?1=m724qjhjwYKlpSVpuhY3jYtTSxQ8EgsKKmMUnDKLSjJSEisVSvIVIvNLuWxs9LhUHMDIUMElNbFIAagTyIVohZoAMwkA)
Beats vanilla shell by one byte, despite having a one-byte longer name!
[Answer]
# [Uiua](https://www.uiua.org/), 45 bytes [SBCS](https://www.uiua.org/pad?src=0_8_0__IyBTaW5nbGUtYnl0ZSBjaGFyYWN0ZXIgc2V0IGZvciBVaXVhIDAuOC4wLCB3cml0dGVuIGluIFVpdWEgMC44LjAKIyBXcml0dGVuIGhhc3RpbHkgYnkgVG9ieSBCdXNpY2stV2FybmVyLCBAVGJ3IG9uIFN0YWNrIEV4Y2hhbmdlCiMgQ3JlYXRlZCAyNyBEZWNlbWJlciAyMDIzIAojIFVwZGF0ZWQgMTggSmFudWFyeSAyMDI0CgojIEFTQ0lJIGlzIGNvbXB1dGVkIGRpcmVjdGx5LCBidXQgaWYgbW9yZSBzcGFjZSBpcyBuZWVkZWQsCiMgbW9zdCBvZiB0aGUgY29udHJvbCBjb2RlcyBjYW4gYmUgcmVwbGFjZWQuCgpBU0NJSSDihpAgKyBAXDAg4oehMTI4CgojIEFsbCBvZiBVaXVhJ3MgZ2x5cGhzLCAKIyBpbmNsdWRpbmcgZGVwcmVjYXRlZCDijIUsIOKKoCwgYW5kIOKKnSwgYXMgdGhleSBzdGlsbCB3b3JrIGFzIG9mIEphbnVhcnkgMTQuCgpVSVVBIOKGkCAi4peM4oiYwqzCscKv4oy14oia4peL4oyK4oyI4oGF4omg4omk4omlw5fDt-KXv-KBv-KCmeKGp-KGpeKIoOKEguKnu-KWs-KHoeKKouKHjOKZrcKk4ouv4o2J4o2P4o2W4oqa4oqb4oqd4pe04pew4pah4ouV4omN4oqf4oqC4oqP4oqh4oav4piH4oaZ4oaY4oa74per4pa94oyV4oiK4oqX4oin4oi14omh4oqe4oqg4o2l4oqV4oqc4oqQ4ouF4oqZ4oipwrDijIXijZziioPiqr7iipPii5TijaLirJrijaPijaTihqzihqvimoLOt8-Az4TiiJ7iuK7ihpAiCgojIEFsbCBjaGFyYWN0ZXJzIFVpdWEgdXNlcyBmb3IgcHJldHR5LXByaW50aW5nLgojIENhbiBiZSByZW1vdmVkIGlmIG5lY2Vzc2FyeS4KCkRSQVdJTkcg4oaQICLila3ilIDilbfila_in6bin6fijJzijJ_ilZPilZ_ilZwiCgojIEZ1bGwgU0JDUyBjdXJyZW50bHkgb25seSB1c2VzIDIyNS8yNTYgYXZhaWxhYmxlIGNvZGVwb2ludHMuCgpTQkNTIOKGkCDiioLiioIgQVNDSUkgVUlVQSBEUkFXSU5HCgojIEVuY29kZSBjb252ZXJ0cyBzdHJpbmcgdG8gU0JDUyBieXRlcy4KIyBEZWNvZGUgY29udmVydHMgYnl0ZXMgdG8gc3RyaW5nCgpFbmNvZGUg4oaQIOKKlzpTQkNTCkRlY29kZSDihpAg4oqPOlNCQ1MKClBhdGhVQSDihpAgInRlc3RVQS51YSIKUGF0aFNCQ1Mg4oaQICJ0ZXN0U0JDUy5zYmNzIgoKIyBFbmNvZGVVQSB0YWtlcyBhIC51YSBmaWxlIGFuZCB3cml0ZXMgU0JDUyBieXRlcyB0byBQYXRoU0JDUwojIEVuY29kZVVBIHRha2VzIGEgLnNiY3MgZmlsZSBhbmQgd3JpdGVzIFVpdWEgc291cmNlIHRvIFBhdGhVQQoKRW5jb2RlVUEg4oaQICZmd2EgUGF0aFNCQ1MgRW5jb2RlICZmcmFzCkRlY29kZVNCQ1Mg4oaQICZmd2EgUGF0aFVBIERlY29kZSAmZnJhYgoKIyBFeGFtcGxlczoKIyAKIyBXcml0ZSB0byAudWEgZmlsZToKIyAgICZmd2EgUGF0aFVBICLijYniip484oqeK-KHoTPil4viiKkow7cyNSnih6EyNDDih6E4MCIKIyBFbmNvZGUgdG8gYSAuc2JjcyBmaWxlOgojICAgRW5jb2RlVUEgUGF0aFVBCiMgRGVjb2RlIGEgLnNiY3MgZmlsZToKIyAgIERlY29kZVNCQ1MgUGF0aFNCQ1MK)
```
⍥(&p⊂"Happy Birthday ")4.,"Dear Uiua""to You"
```
[Try it online!](https://www.uiua.org/pad?src=0_8_0__4o2lKCZw4oqCIkhhcHB5IEJpcnRoZGF5ICIpNC4sIkRlYXIgVWl1YSIidG8gWW91Igo=)
## Explanation
```
⍥(&p⊂"Happy Birthday ")4.,"Dear Uiua""to You"
                                     "to You" # push string "to You" to stack
                          "Dead Uiua"         # push string "Dear Uiua" to stack
                         ,                    # duplicate 2nd-to-top stack element
                        .                     # duplicate top stack element
⍥(                    )4                      # repeat this function 4 times:
     "Happy Birthday "                        # push string "Happy Birthday " to stack
    ⊂                                         # join end-to-end
  &p                                          # print to stdout with newline
```
[Answer]
## JavaScript, 73
Run this in the console
```
for(h="",i=4;i;)h+='\nHappy Birthday '+(--i-1?'to You':'Dear JavaScript')
```
[Answer]
# C++, 136
```
#include<iostream>
int main(){static int i=0;std::cout<<"Happy Birthday "<<(i==2?"Dear C++":"to You")<<std::endl;return ++i<4?main():0;}
```
[Answer]
# B - 109
(caveat: arguably not valid B, difficult to say - works [with this](https://github.com/Leushenko/ybc))
```
main()v(4,"Happy Birthday to You   HDear B");v(i,s){s[5]=i&5?'u':134744072;s[6]=&-247;i?puts(s)&v(i-1,s):0;}
```
[Answer]
EcmaScript 6 - 64 о\_О
```
[1,1,0,1].map(i=>"Happy Birthday "+(i?"to you":"ES6")).join("\n")
```
[Answer]
# PowerShell 92 (fixed)
```
$a="happy birthday to you";$a;$a;write-host -no  $a.TrimEnd('to you');"y dear powershell" ;$a
```
this one is longer than the other PS solution but is unique and actually out puts the correct string
## OLD -Powershell- - 62
```
$a="happy birthday to you";$a;$a;write "$a dear powershell";$a
```
[Answer]
## ><> 76 Bytes
Since it wasn't here already...
```
0>"Happy Birthda"{1+:}3-?vv
v^?=1l<;?=5}:{a"uoY oT y"<>"y Dear ><>"a
>{{o} ^
```
[Answer]
# JS 70 Bytes
```
alert([c=(a="Happy Birthday")+" to You",c,a+" Dear JS",c].join("\n"));
```
[Answer]
# Swift, 68 bytes
```
(1...4).map{print("Happy Birthday "+($0==3 ?"dear Swift":"to You"))}
```
also differently:
```
print({$0+$1+$0+$1+$0+"dear Swift"+$0+$1}("\nHappy Birthday ","to You"))
```
with 71 bytes
[Answer]
# HPPPL (HP Prime Programming Language), 88
```
n:=char(10);a:="Happy Birthday ";b:="To You";c:="Dear HPPPL";d:=a+b+n;print(d+d+a+c+n+d)
```
Result:
[![Happy Birthday To You HPPPL](https://i.stack.imgur.com/nuuJ8.png)](https://i.stack.imgur.com/nuuJ8.png)
HPPPL is the programming language for the HP Prime color graphing calculator/CAS. An emulator is available at the HP website.
[Answer]
# [Stringy](https://github.com/m654z/Stringy), 78 bytes
```
(Happy birthday );a to you;p;p;^ to you!dear Stringy;p;^ dear Stringy!to you;p
```
[Answer]
# [Mouse-2002](https://github.com/catb0t/mouse15), 70 bytes
Mouse isn't very skilled at [kolmogorov-complexity](/questions/tagged/kolmogorov-complexity "show questions tagged 'kolmogorov-complexity'"). :(
```
$H"Happy Birthday "@
$Y"to you!"@
#H;#Y;#H;#Y;#H;"Dear Mouse!"#H;#Y;$
```
The exclamation points print newlines, not themselves, and the `$H` and `$Y` are functions, not variables, because poor Mouse can't comprehend strings.
## MUSYS, MUsic-SYStem, Mouse's predecessor, 93 bytes
```
"Happy Birthday to you!Happy Birthday to you!Happy birthday dear MUSYS!Happy Birthday to you"
```
[Answer]
# [Staq](http://esolangs.org/wiki/Staq), ~~67~~ 66 chars
```
{h"Happy Birthday "}{T"To You"}{D"Dear Staq"}{N&iiqi,;}hTNhTNhDNhT
```
Result:
```
Executing D:\codegolf\Happy Birthday Staq.staq
Happy Birthday To You
Happy Birthday To You
Happy Birthday Dear Staq
Happy Birthday To You
Execution complete.
>
```
[Answer]
# JavaScript, 70 Bytes
```
a="Happy Birthday ";b=a+"to You\n";c=a+b;d=c+c+a+"Dear JavaScript\n"+c
```
**Best answer JavaScript answer so far!**
```
a="Happy Birthday ";
b=a+"to You\n";
c=a+b;                         // Create string "Happy Birthday to You\n"
d=c+c+a+"Dear JavaScript\n"+c  // Create song
```
Implementation:
```
a="Happy Birthday ";b=a+"to You\n";c=a+b;d=c+c+a+"Dear JavaScript\n"+c
alert(d);
console.log(d);
```
[Answer]
# [Edited Processing.js](https://github.com/Khan/processing-js) 80 bytes
```
var a="\nhappy birthday to you";print(a+a+"\nHappy birthday processing.js"+a);
```
Processing JS is a language that is fun but I am lazy and use an edited version that also is ungolfable.
[Try it online](https://www.khanacademy.org/computer-programming/new-program/5992443128643584) Println was used so you don't have to open the console :P
Khanacademy version
[Answer]
# Sprects, 49 bytes
```
.12121Dear Sprects\n12.1Happy Birthday .2to You\n
```
[Try it here](http://dinod123.neocities.org/interpreter.html)
[Answer]
# C, 74 bytes
```
i=5;main(){while(--i)printf("Happy Birthday %s\n",i-2?"to You":"Dear C");}
```
**Detailed**
```
void main()
{
    int i = 5;
    while (--i > 0)
    {
        printf("Happy Birthday %s\n",
        i!=2 ? "to You" : "Dear C" );
    }
}
```
[Answer]
## C++, 92 bytes
```
#include<iostream>
int main(int c){for(c=4;c--;)std::cout<<"Happy Birthday "<<(c-1?"To You":"Dear C++")<<"\n";}
```
[Try it online](https://tio.run/nexus/cpp-gcc#U87MS84pTUm1ycwvLilKTcy1@5@ZV6KQm5iZpwFiJGtWp@UXaSTbmlgn6@paaxaXpFhZJeeXltjYKHkkFhRUKjhlFpVkpCRWKijZ2Ggk6xraK4XkK0TmlypZKbmkJhYpOGtrK2kCVcfkKVnX/v8PAA)
[Answer]
# Batch, 72 bytes
```
@SET h=@ECHO Happy Birthday
%h%to You
%h%to You
%h%Dear Batch
%h%to You
```
[Answer]
# Fourier, 52 bytes
```
|`Happy Birthday `|A|`to You
`|BABABA`Dear Fourier
`AB
```
[**Try it online!**](https://beta-decay.github.io/editor/?code=fGBIYXBweSBCaXJ0aGRheSBgfEF8YHRvIFlvdQpgfEJBQkFCQWBEZWFyIEZvdXJpZXIKYEFC)
Nothing particularly special except that it demonstrates that you can have newlines in string prints.
[Answer]
# [Braingolf](https://github.com/gunnerwolf/braingolf), 69 bytes
```
"Happy Birthday to You
"VR{.M}v&,6>[$_]"dear Braingolf
"R!&@!&@v&@c&@
```
[Try it online!](https://tio.run/##SypKzMxLz89J@/9fySOxoKBSwSmzqCQjJbFSoSRfITK/lEspLKhaz7e2TE3HzC5aJT5WKSU1sUjBCaaPSylIUc0BiMrUHJLVHP7/BwA "Braingolf – Try It Online")
## Explanation
```
"Happy Birthday to You
"
```
Pushes "Happy Birthday to You\n" to the stack
```
VR{.M}
```
Creates a 2nd stack and duplicates the contents of the first stack to it, in reverse order
```
v&,
```
Switches to the 2nd stack and flips the entire stack
```
6>[$_]
```
Drops the last 7 items from the 2nd stack
```
"dear Braingolf
"
```
Pushes "dear Braingolf\n" to the 2nd stack
```
R!&@!&@
```
Prints the contents of the first stack twice
```
v&@
```
Prints the contents of the 2nd stack
```
c&@
```
Prints the contents of the first stack
[Answer]
# [Cubically](https://github.com/aaronryank/cubically), 813 bytes
I guess this belongs here now too! Loops haven't been added to the language yet, so this is the best I can manage.
```
+53@6:5+2/1+55@6:4/1+552@66+1@6:5/1+3@6/1+52@6:5+1/1+551@6+1@6:5+3/1+552@6:5/1+551@6:1/1+551@6:5+2/1+55@6:4/1+553@6:5/1+3@6:5+3/1+552@6:3/1+552@6:5/1+3@6:5+3/1+54@6:3/1+552@6:5+53@6:1/1+1@6:5+3@6:5+2/1+55@6:4/1+552@66+1@6:5/1+3@6/1+52@6:5+1/1+551@6+1@6:5+3/1+552@6:5/1+551@6:1/1+551@6:5+2/1+55@6:4/1+553@6:5/1+3@6:5+3/1+552@6:3/1+552@6:5/1+3@6:5+3/1+54@6:3/1+552@6:5+53@6:1/1+1@6:5+3@6:5+2/1+55@6:4/1+552@66+1@6:5/1+3@6/1+52@6:5+1/1+551@6+1@6:5+3/1+552@6:5/1+551@6:1/1+551@6:5+2/1+55@6:4/1+553@6:5/1+3@6+4@6:2/1+551@6:5+2/1+55@6:5+1/1+552@6:5/1+3@6:4/1+52@6:5+53@6:5+3/1+55@6:5+1/1+551@6:5+51@6:5+2/1+55@6:5+52@66:4/1+553@6:1/1+1@6:5+3@6:5+2/1+55@6:4/1+552@66+1@6:5/1+3@6/1+52@6:5+1/1+551@6+1@6:5+3/1+552@6:5/1+551@6:1/1+551@6:5+2/1+55@6:4/1+553@6:5/1+3@6:5+3/1+552@6:3/1+552@6:5/1+3@6:5+3/1+54@6:3/1+552@6:5+53@6
```
[Try It Online!](https://tio.run/##7ZGxDoAgDER/xb2DFiiDE7@iTiasDn490ioCwcnNxK3wjrtrWLZ5XSbv9xCAtLMjgeoRiOJoZFDOWkAm8RgVfKlEiMIjOjHopBepkPHWtMY6e1aPa5uCmhqefTngiv/bv2kPXEw9SVNKuYzJFahcvS7FtDGTbYr8T/9cCNTh0CEd)
[Answer]
# [Pyth](http://pyth.readthedocs.io), 49 bytes
Since the other Pyth answer is quite outdated and *non-competing* has been removed [per meta consensus](https://codegolf.meta.stackexchange.com/questions/12877/lets-allow-newer-languages-versions-for-older-challenges), here is a newer answer:
```
K"Happy Birthday "J+K"to You\n"+*J2+K"Dear Pyth"J
```
**[Try it online!](http://pyth.herokuapp.com/?code=K%22Happy+Birthday+%22J%2BK%22to+You%5Cn%22%2B%2aJ2%2BK%22Dear+Pyth%22J&debug=0)**
# [Pyth](http://pyth.readthedocs.io), 50 bytes
```
K+"Happy Birthday to You"b+++KK++<K15"Dear Pyth"bK
```
**[Try it online!](http://pyth.herokuapp.com/?code=K%22Happy+Birthday+to+You%5Cn%22%2B%2B%2BKK%2B%3CK15%22Dear+Pyth%5Cn%22K&debug=0)**
[Answer]
# Golfscript, 56 bytes
Thanks, professorfish!
```
"Happy Birthday ":h"to You\n"+:s s h"dear Golfscript\n"s
```
Output:
```
Happy Birthday to You
Happy Birthday to You
Happy Birthday dear Golfscript
Happy Birthday to You
```
]


[Question]
      []


[Question]
      [
A polyquine is both quine and polyglot.1 You are to write a quine which is valid in at least two different languages. This is code golf, so the shortest answer (in bytes) wins.
1 I made that up. Or rather, [Geobits did](http://chat.stackexchange.com/transcript/240?m=17522730#17522730). Apparently, [he wasn't the first one either](https://code.google.com/p/mchouza/source/browse/trunk/quine/polyquine.c?r=122), though.
### Rules for Quines
Only *true* quines are accepted. That is, you need to print the entire source code verbatim to STDOUT, **without**:
* reading your source code, directly or indirectly.
* relying on a REPL environment which just simply evaluates and prints every expression you feed it.
* relying on language features which just print out the source in certain cases.
* using error messages or STDERR to write all or part of the quine. (You may write things to STDERR or produce warnings/non-fatal errors as long as STDOUT is a valid quine and the error messages are not part of it.)
Furthermore, your code *must* contain a string literal.
### Rules for Polyglots
The two languages used must be distinctly different. In particular:
* They must not be different versions of the same language (e.g. Python 2 vs. Python 3).
* They must not be different dialects of the same language (e.g. Pascal vs. Delphi).
* One language may not be a subset of the other one (e.g. C vs. C++).

[Answer]
# CJam/GolfScript, 34 bytes
```
{"__X.0#@@?LL
;~"N}__X.0#@@?LL
;~
```
The byte count contains a trailing linefeed, since the program wouldn't be a quine without it.
While CJam and GolfScript are *very* similar in some aspects, there are *a lot* of differences. To make this an "honest" polyquine, I decided to rely on the *differences* as much as possible. Except for the block and string syntax (which the languages share with oh so many others), no part of the code achieves exactly the same in both languages.
The online GolfScript interpreter has a bug; this program works only with the official interpreter.
### Example run
```
$ cat polyquine
{"__X.0#@@?LL
;~"N}__X.0#@@?LL
;~
$ md5sum polyquine <(cjam polyquine) <(golfscript polyquine)
e2f1f3cd68abbbceec58080513f98d9a  polyquine
e2f1f3cd68abbbceec58080513f98d9a  /dev/fd/63
e2f1f3cd68abbbceec58080513f98d9a  /dev/fd/62
```
### How it works (CJam)
```
" Push that block.                                                                        ";
{"__X.0#@@?LL
;~"N}
" Push two copies of the block, 1 (computed as 1**0) and rotate the block copies on top.  ";
__X.0#@@
" If 1 is truthy (oh, the uncertainty), execute the first copy; else, execute the second.
  Evaluating the block pushes the string it contains; N pushes a linefeed.                ";
?
" Push two empty arrays.                                                                  ";
LL
" Discard one empty array and dump the second.                                            ";
;~
" (implicit) Print all items on the stack.                                                ";
```
### How it works (GolfScript)
```
# Push that block.
{"__X.0#@@?LL
;~"N}
# Push a copy of the block; _ and X are noops, # initiates an inline comment.
__X.0#@@?LL
# Discard the 0 and execute the copy of the block.
# Evaluating the block pushes the string it contains; N is a noop.
;~
# (implicit) Print all items on the stack, followed by a linefeed.
```
---
# CJam/GolfScript, 12 bytes
```
{"0$~"N}0$~
```
Cheaty solution that avoids the languages' differences as much as possible.
Try it online:
* [CJam](http://cjam.aditsu.net/)
* [GolfScript](http://golfscript.apphb.com/?c=eyIwJH4iTn0wJH4%3D)
### How it works (CJam)
```
 "0$~"       " Push that string.                                                          ";
      N      " Push a linefeed.                                                           ";
{      }0$~  " Push a copy of the block and execute it.                                   ";
             " (implicit) Print the stack.                                                ";
```
### How it works (GolfScript)
```
 "0$~"       # Push that string.
      N      # Undefined token (noop).
{      }0$~  # Push a copy of the block and execute it.
             # (implicit) Print the stack, followed by a linefeed.
```
[Answer]
## C#/Java, 746 bytes
I use the property that chars in Java can be written as identical unicode sequences. If we have `A` instruction for C# compiler and `B` instruction for Java, we can use the following code fragment:
```
//\u000A\u002F\u002A
A//\u002A\u002FB
```
It will be "recognized" by the following way with C#:
```
//\u000A\u002F\u002A
A//\u002A\u002FB
```
And by the following way by Java:
```
//
/*
A//*/B
```
Because of `\u000A` is line break, `\u002F` is `/` and `\u002A` is `*` in Java.
So the final polyglot-quine is:
```
//\u000A\u002F\u002A
using System;//\u002A\u002F
class Program{public static void//\u000A\u002F\u002A
Main//\u002A\u002Fmain
(String[]z){String s="//@#'^using System;//'#^class Program{public static void//@#'^Main//'#main^(String[]z){String s=!$!,t=s;int[]a=new int[]{33,94,38,64,35,39,36};String[]b=new String[]{!&!!,!&n!,!&&!,!&@!,!&#!,!&'!,s};for(int i=0;i<7;i++)t=t.//@#'^Replace//'#replace^(!!+(char)a[i],b[i]);//@#'^Console.Write//'#System.out.printf^(t);}}",t=s;int[]a=new int[]{33,94,38,64,35,39,36};String[]b=new String[]{"\"","\n","\\","\\u000A","\\u002F","\\u002A",s};for(int i=0;i<7;i++)t=t.//\u000A\u002F\u002A
Replace//\u002A\u002Freplace
(""+(char)a[i],b[i]);//\u000A\u002F\u002A
Console.Write//\u002A\u002FSystem.out.printf
(t);}}
```
However, the size is too huge because of languages verbosity.
Compilation available on ideone.com: [C#](http://ideone.com/JrrbeL), [Java](https://ideone.com/PzJxcB).
[Answer]
### Python 3 and JavaScript, 134 bytes
Here's my (final?) attempt:
```
a='eval(a.split(" ")[2%-4]),1//2# q=String.fromCharCode(39);console.log("a="+q+a+q+a.slice(-8)) print(a[-12:]%a) a=%r;eval(a)';eval(a)
```
It can probably be golfed a bit more, especially if anyone knows a better way to get single quotes in JavaScript.
---
Boiled down, the program looks like this:
```
a='a long string';eval(a)
```
The `eval()` function will evaluate expressions in both languages. So the long string gets executed:
```
eval(a.split(" ")[2%-4]),1//2# ... the rest gets commented out
```
This splits the long string by spaces and evaluates the substring indexed by `2%-4`. JavaScript will run the third substring (`2 % -4 == 2`) and Python the second last (`2 % -4 == -2`), because their modulo operators behave differently for negatives.
The rest of the string gets ignored in both languages. JavaScript stops at the `//`, while Python sees it as integer division and stops at the `#`.
So JavaScript prints the source code to the console here:
```
q=String.fromCharCode(39);console.log("a="+q+a+q+a.slice(-8))
```
And Python here:
```
print(a[-12:]%a)
```
Both make use of the final part of the string, which is a template of the program:
```
a=%r;eval(a)
```
[Answer]
# Ruby/Perl/PHP, 52
```
$b='$b=%c%s%c;printf$b,39,$b,39;';printf$b,39,$b,39;
```
Copied verbatim from [Christopher Durr](http://www.nyx.net/~gthompso/self_perl.txt)'s Perl quine.
This is rules abuse. Ruby and Perl are definitely not the same language, nor is Perl a subset of Ruby (most of the linked Perl quines don't work in Ruby, for example). But Ruby was designed to be able to look a lot like Perl if you want it to, and this happens a lot when golfing.
[Answer]
# PHP/Perl - 171
```
#<?PHP$s=1;$t="";
$a='%s<%cPHP$s=1;$t="";%c$a=%c%s%c;$t==$s?$t="#":$s;printf($a,$t,63,10,39,$a,39,10,63);%c#%c>';$t==$s?$t="#":$s;printf($a,$t,63,10,39,$a,39,10,63);
#?>
```
Run with:
```
$ php quine.pl
$ perl quine.pl
```
The `php` code is actually running (not just printing itself).
[Answer]
# Bash/Ruby, ~~104~~ 82
```
"tee`#";puts <<a*2+'a'#`" -<<'a';echo a
"tee`#";puts <<a*2+'a'#`" -<<'a';echo a
a
```
Older version:
```
"alias" "puts=f()(tee -;echo a);f"
puts <<a *2+"a"
"alias" "puts=f()(tee -;echo a);f"
puts <<a *2+"a"
a
```
# Bash/Ruby, 128 without undefined behavior
```
"alias" 'puts=f()(a=`cat`;echo "$a
$a
a");f'
puts <<'a' *2+"a"
"alias" 'puts=f()(a=`cat`;echo "$a
$a
a");f'
puts <<'a' *2+"a"
a
```
[Answer]
# Bash/GolfScript, 73
```
.~0 ()
{
    declare "-f" @* ".~0" " ()
"+@n.;
    echo '.~0;'
}
.~0;
```
There is a trailing space on each of the first 3 lines.
# Bash/GolfScript, 78
```
alias :a~a.='eval "alias :a~a."\
;set [61 39]+a[39]+n"":a;echo ":a~a."'
:a~a.
```
[Answer]
## [Perl 5](https://www.perl.org/)/[Ruby](https://www.ruby-lang.org/)/[JavaScript (Node.js)](https://nodejs.org)/[Bash](https://www.gnu.org/software/bash/)/[Python 2](https://docs.python.org/2/)/[PHP](https://php.net/), 1031 bytes
```
s=1//2;_=r'''<?#/.__id__;s=+0;#';read -d '' q<<'';s=\';Q='echo s=1//2\;_=r$s$s$s\<\?\#/.__id__\;s=+0\;#$s\;read -d $s$s q\<\<$s$s\;s=\\$s\;Q=$s$Q$s\;eval\ \$Q;echo $q';eval $Q
$_='eval("0"?0?"def strtr(s,f,t);s.tr(f,t) end;class String;def chr(n);self+n.chr end;end":"$u=strtr=(s,f,t)=>[...f].reduce((s,a,i)=>s.replace(RegExp(a,`g`),t[i]),s);printf=console.log;(S=String).prototype.chr=function(n){return this+S.fromCharCode(n)}":[]&&"sub strtr{eval q(q(X)=~y/X/X/r)=~s/X/shift/ger}");printf(strtr("%s<?#/.__id__;s=+0;#j;read -d jj q<<jj;s=zj;Q=jecho s=1//2z;_=rksksksz<z?z#/.__id__z;s=+0z;#ksz;read -d ksks qz<z<ksksz;s=zzksz;Q=kskQksz;evalz zkQ;echo kqj;eval kQwk_=j%sj;eval(k_);//;#jjj;f=jjjs=1//2;_=r%%s%%s%%s;f=%%s%%s%%s;q=_[18]*3;print f%%%%(q,_,q,q,f,q)jjj;q=_[18]*3;print f%%(q,_,q,q,f,q)%s","jkwz","".chr(39).chr(36).chr(10).chr(92).chr(92)),[]&&"s=1//2;_=r".chr(39).chr(39).chr(39),$_,$u?"":"".chr(10));';eval($_);//;#''';f='''s=1//2;_=r%s%s%s;f=%s%s%s;q=_[18]*3;print f%%(q,_,q,q,f,q)''';q=_[18]*3;print f%(q,_,q,q,f,q)
```
[Verify it online!](https://tio.run/##jVPbcpswEH3nKzQYB2gU7MTTThNZ8UOmH0DzkhnjIZiLARMukmhq4vTX3RU4JGnsSS1gb0dnd7Xy0uPxbvfoozMfWUle1sISSUGUh@DrO7sMWfbGga6RVdRCWmVGFFYvN4ejbEmUvAjCw9GUE2UJFRyO8hjybkRc5Ecyb4gy6ACTY4gJUMQlOgsQjwsm3KIMc1d4K3qUNC6JArSfb9rKM9nK1rddEVvZ6F6fbNu@Xnm9LPuvUo6wHmJTBu2U9q6nMsNsiVOOeYzLDTwTDPkwQJ/38zyG7FG7Hafno9EFcSnTdX06G4ws100C1yWcno7JQCcs9ALZg66jajrVdQg4OrGpHvpxgbrtjtyvcbmcqTNzehanpXHIAAI9k4ShCoDTdoMkdKS0Kdi21MJfXuYgR7NJm0Sr9NaFNFvRXMgMuqGO1dl4pgZhhLhgghkcR1iYhFugSw2FeUD8zOMc3QqW5CsisX7MjBxQYRad5hZYLQxe9UrVatpS0T0XvZ5blhUtLBYGtR8a4PZwAm4OnjLzwPUzXP34XRoevl/dm1jMk4WJuUlKyCci6hc5L7LQyooVMW5pV4ZplawQhdiUocxPozr34R7kUNYTC0XNciTihJ/eWhErHm5ij93AhYDos3o1X5ycqLxedi0/tYdSGZVxZ9I/m9EdLAYaB8njJBKjVcie1ZdyjO6c1CH/OOe0n06ayjmnKQSaFGaSvplzI@e85nI102bW9CxNS9OQAQR6JglDFQCn7QZJ2EhpU7Btqcn6G9Ss93NeV2k357X9uHZpOuSdbaxdk4xGUCWUFVH4vt7a4ZB3DwRe9Yq68/Pviy@TrnUUDeFnVNjFFawIV6akOoB6hxlyFavp@rEBocpZGZNLs5PfOnk@7uTlRS9N3A2pr/Cfna8Say7W6pkKN099YTNJd9UNbd8y/CuhM/i@aZnLJfvtlM/akBQfMe8gyl8 "Bash – Try It Online")
Based on my updates to [this answer](https://codegolf.stackexchange.com/a/162690/9365), I thought I'd try and optimise out the code that prints a different permutation, but ended up adding in Bash, which added a load more bytes anyway. Whilst this is more optimised than my first attempt (saved over 300 bytes) I'm sure it can still be golfed further.
---
## Alternative [Perl 5](https://www.perl.org/)/[Ruby](https://www.ruby-lang.org/)/[JavaScript (Node.js)](https://nodejs.org)/[Bash](https://www.gnu.org/software/bash/)/[Python 2](https://docs.python.org/2/)/[PHP](https://php.net/), 1040 bytes
```
s=1//2;_=r'''<?#/.__id__;s=+0;#';read -d '' q<<'';s=\';Q='echo s=1//2\;_=r$s$s$s\<\?\#/.__id__\;s=+0\;#$s\;read -d $s$s q\<\<$s$s\;s=\\$s\;Q=$s$Q$s\;eval\ \$Q;echo $q';eval $Q
$_='$z=0?"$&".next+92 .chr+10 .chr: 0..a||eval("printf=console.log;unescape`$%27%5C%0Ak`");$q=$z[1]?$z[1]:h^O;printf("%s%s%s%s<?#/.__id__;s=+0;#%s;read -d %s%s q<<%s%s;s=%s%s;Q=%secho s=1//2%s;_=r%ss%ss%ss%s<%s?%s#/.__id__%s;s=+0%s;#%ss%s;read -d %ss%ss q%s<%s<%ss%ss%s;s=%s%s%ss%s;Q=%ss%sQ%ss%s;eval%s %s%sQ;echo %sq%s;eval %sQ%s%s_=%s%s%s;eval(%s_);//;#%s%s%s;f=%s%s%ss=1//2;_=r%%s%%s%%s;f=%%s%%s%%s;q=_[18]*3;print f%%%%(q,_,q,q,f,q)%s%s%s;q=_[18]*3;print f%%(q,_,q,q,f,q)%s",[]&&"s=1//2;_=r",$r=[]&&$q,$r,$r,$q,$q,$q,$q,$q,$b=$z[2]?$z[2]:chr(92),$q,$q,$b,$d=$z[0]?$z[0]:h^L,$d,$d,$b,$b,$b,$b,$b,$d,$b,$d,$d,$b,$b,$d,$d,$b,$b,$b,$d,$b,$d,$d,$d,$b,$b,$b,$d,$d,$q,$d,$n=$z[3]?$z[3]:chr(10),$d,$q,$_,$q,$d,$q,$q,$q,$q,$q,$q,$q,$q,$q,$z[4]?"":$n);';eval($_);//;#''';f='''s=1//2;_=r%s%s%s;f=%s%s%s;q=_[18]*3;print f%%(q,_,q,q,f,q)''';q=_[18]*3;print f%(q,_,q,q,f,q)
```
[Verify it online!](https://tio.run/##jVNtk5pADP7Or9jBRbRyiNKb9lyp0@nXznT4LJYDwcMr5W3xWi397TZZkNM7maub2WySJ092E/Q9Hh2Pv9bkZk30bZLtSr3cpkz6Gdxe2FlYxGcO8ono6a5EK4uZVOz8/fVo4TMpSYPwevSRM8mHG1yP8gjq7ssoTToq75nUqwFmF8IEiigjNwHhUVqUbpqFiVt6D1YnaZQxCWjfTqqwJxU@vaovUeFDm7NZiXc983px/F9X6WC9xib1xJQa158s1gpfe@Qaj7RsD2JqUE8D6N9mnl3IFnU8cmsyHk@ZaxWqqs4XvbHuutvAdRm3RgbrqawIvQDfoKokn89VFQKOymxLDddRSup0B/Mpx@XMnYXTsjiCxmE9CLRMCCM5AOciAQkd1LYFto2n8MmLHeJQm4kiNFeFi1Bboq6l0oNlLGTal/Uk/F2O7qZEX0fFaGIIPSOGrntVhRkDOSu2Sbmx1mnC0zjU4/SB7ZKQr70svKfK9INy@0UxPv@4l4eM5hY9LCerhdhn0fdvrM4eyAqv1@sGKbx9FwKwR6ghKpQN6qxR4IFOKZyfBMALhbekInFkgOqJ8Bk34kkuMuan7KZKfcZSoO3awtfDdTDYdFHheeMnAqVwt8kWzgHYQzYeY2Xh3Jy42y9EAVMIxtpzbrnLycfVO7PuFtko8BvkmqvlsDZaPmwIrwBfwGRtuer35eeKskYLC300h5OQ/FJ8nNlUzGy6msH4B3fTYRvUaIBxQ8QNnOlXcAnxLyU47cGZJ@gAvPAHohjsCRYzRTGzvszEGJ7i7gmVd8th@X61kOUZTYas/uYHtJkK/D2h7bCfzeNyUG82GCleYy4g0j8 "Bash – Try It Online")
A little closer to my original approach, but the repetition of the args for `printf` is still insane. Using positional arguments instead make this only work in Chrome and is tricky to get working in PHP as well because the `$s` in `%1$s` is interpolated, but could save a lot of bytes, perhaps using a combination of the two approaches...
[Answer]
## Ruby/Mathematica, 225 bytes
Here is my own very beatable polyquine (which serves as example and proof-of-concept):
```
s="s=%p;puts s%%s;#Print[StringReplace[s,{(f=FromCharacterCode)@{37,112}->ToString@InputForm@s,f@{37,37}->f@37}]]&@1";puts s%s;#Print[StringReplace[s,{(f=FromCharacterCode)@{37,112}->ToString@InputForm@s,f@{37,37}->f@37}]]&@1
```
The first part is based [on this Ruby quine](https://codegolf.stackexchange.com/a/80/8478) and is basically:
```
s="s=%p;puts s%%s;#MathematicaCode";puts s%s;#MathematicaCode
```
The string assignment is exactly the same in Mathematica. The `puts s%s` is interpreted as a product of 4 symbols: `puts`, the string `s`, `%` (the last REPL result or `Out[0]` if it's the first expression you evaluate) and another `s`. That's of course completely meaningless, but Mathematica doesn't care and `;` suppresses any output, so this is just processed silently. Then `#` makes the rest of the line a comment for Ruby while Mathematica continues.
As for the Mathematica code, the largest part of it, is to simulate Ruby's format string processing without using any string literals. `FromCharacterCode@{37,112}` is `%p` and `FromCharacterCode@{37,112}` is `%%`. The former gets replaced with the string itself, (where `InputForm` adds the quotes) the latter with a single `%`. The result is `Print`ed. The final catch is how to deal with that `#` at the front. This is Mathematica's symbol for the first argument of a pure (anonymous) function. So what we do is we *make* all of that a pure function by appending `&` and immediately invoke the function with argument `1`. Prepending a `1` to a function call "multiplies" the result with `1`, which Mathematica again just swallows regardless of what kind of thing is returned by the function.
[Answer]
# reticular/befunge-98, 28 bytes [noncompeting]
```
<@,+1!',k- ';';Oc'43'q@$;!0"
```
[Try reticular!](http://reticular.tryitonline.net/#code=PEAsKzEhJyxrLSAnOyc7T2MnNDMncUAkOyEwIg&input=) [Try befunge 98!](http://befunge-98.tryitonline.net/#code=PEAsKzEhJyxrLSAnOyc7T2MnNDMncUAkOyEwIg&input=)
Anything in between `;`s in befunge is ignored, and `!` skips into the segment between `;`s for reticular. Thus, reticular sees:
```
<@,+1!',k- ';';Oc'43'q@$;!0"
<                             move left
                           "  capture string
                          0   push zero
                        ;!    skip `;` (end program)
                       $      drop zero
                     q@       reverse TOS
                 '43'         push 34 (")
                c             convert to char
               O              output all
              ;               end program
```
Befunge sees:
```
<@,+1!',k- ';';Oc'43'q@$;!0"
<                            move left
                           " capture string
                         !0  push 1
              ;         ;    skip this
         - ';'               push 27
       ,k                    output top 27 chars
   +1!'                      push 34 (")
  ,                          output "
 @                           end program
```
[Answer]
# C/PHP, ~~266~~ ~~304~~ ~~300~~ ~~282~~ ~~241~~ 203 + 10 bytes
```
//<?php
function main($a){printf($a="%c//<?php%cfunction main(%ca){printf(%ca=%c%s%c,13,10,36,36,34,%ca,34,36,10,10,10);}%c#if 0%cmain();%c#endif",13,10,36,36,34,$a,34,36,10,10,10);}
#if 0
main();
#endif
```
+10 bytes because compiling in C requires the GCC compiler flag `-Dfunction=`.
How it works (in PHP):
* The PHP interpreter simply prints everything before the `<?php` as HTML. `//` is not a comment in HTML, so it's simply printed.
* `main` is declared as a function with a variable `a`.
* `printf` prints a carriage return (to override the already-printed `//`) and then the source code, using a standard C/PHP quining method.
* `#if 0` is ignored by PHP.
* `main($a)` initializes an empty variable `a`. (Previously used `error_reporting(0)` to ignore errors caused by calling `main()`)
* `#endif` is also ignored by PHP.
How it works (in C):
* `//<?php` is a single-line comment, so it is ignored.
* The `function` keyword is ignored due to the command-line compiler argument `-Dfunction=`.
* GCC and Clang don't care if variables start with or contain `$`. (This saved the day.)
* `printf` prints a carriage return (useless in this instance) and then the source code, using a standard C/PHP quining method.
* `#if 0` ignores everything until the `endif`, so PHP can call `main`.
* `#endif` ends the "ignore me" block.
[Answer]
# [Wumpus](https://github.com/m-ender/wumpus)/[><>](https://esolangs.org/wiki/Fish)/[Befunge-98](https://github.com/catseye/FBBI) 31 bytes
```
"]#34[~#28&o@,k+deg0 #o#!g00
```
[Try it in Wumpus!](https://tio.run/##Ky/NLSgt/v9fSSFW2dgkuk7Z2FAt30EnWzstTdvISkVBOV9ZEcj4/x8A),
[Try it in ><>!](https://tio.run/##S8sszvj/X0khVtnYJLpO2dhQLd9BJ1s7LU3byEpFQTlfWRHI@P8fAA),
[Try it in Befunge-98!](https://tio.run/##S0pNK81LT9W1tPj/X0khVtnYJLpO2dhQLd9BJ1s7LU3byEpFQTlfWRHI@P8fAA)
## How it Works:
### Wumpus Code:
```
  " Start string literal
    Bounce off end of line and come back
  " End string literal
    ]      Push top of stack to bottom
     #34   Push double quote
        [~ Get bottom of stack and swap it with the double quote
          #31    Push 31
             &o@ Print the top 31 items on stack and terminate program
```
### ><> Code:
```
  "    Start string literal
       Wrap when it reaches the end of the line
  "    End string literal
    ]# Clear stack and reflect
  "    Wrapping string literal again, but backwards
                        +2: Copy the space and add 2 to get "
                    #o#!    Skip into the printing loop
                            Exit with an error
```
### Befunge-98 Code:
```
  "   Wrapping string literal
    ] Turn right
    ] Turn right again, going West
  "   Wrapping string literal going West
                    !+2: Get double quote and invert it
                 #o#     Skip over the o instruction
            +2:$         Get double quote
         +ff             Push 30
      @,k                Print 30+1 items from the stack and terminate program.
```
[Answer]
## ><> and CJam, 165 bytes
```
"~~~~~~~~~~~~~~~~~~~~~~~r00gol?!v93*0.Hi
'                               <       .1*5av!?log10oar~~~r
'"`{"`"\"_~e#.21 <.2+4*96;!?log10oa"}_~e#.21 <.2+4*96;!?log10oa
```
To CJam, the program starts with a multi-line string literal. This is escaped with ```, and then it uses the standard quine to print the quine code, as well as a trailing comment.
To ><>, the first `"` starts a string literal that goes through the entire first row, pushing every character to the stack. After that, the trailing spaces (created due to the input being padded) are deleted, and then the stack is reversed. Every character in the stack (i.e. the entire first row) is output, and then it moves down to the second row.
The second row essentially does the same thing, except that it's in the opposite direction, so you don't need to reverse the stack. (I do anyway, because I have to delete the trailing spaces.)
Finally, it moves on to the third line. The only major difference is that you must skip the CJam block, which is done using `.` The single quote captures the entire line (again, backwards), and then it is output.
[Answer]
# C/Lisp, 555 bytes
```
t(setq /*;*/){}main(){char q='\"',s='\\';char*a=
"~%t(setq /*;*/){}main(){char q='~A';char*a=
~S;char*b=/*
)(setq a ~S)
(setq */ ~S;printf(b,s,q,s,s,q,a,q,q,s,s,s,q,s,s,s,s,q,q,b,q/*
)(format t /* a /* a */);}~%";char*b=/*
)(setq a "\\\"',s='\\\\")
(setq */ "
t(setq /*;*/){}main(){char q='%c%c',s='%c%c';char*a=
%c%s%c;char*b=/*
)(setq a %c%c%c%c%c',s='%c%c%c%c%c)
(setq */ %c%s%c;printf(b,s,q,s,s,q,a,q,q,s,s,s,q,s,s,s,s,q,q,b,q/*
)(format t /* a /* a */);}
";printf(b,s,q,s,s,q,a,q,q,s,s,s,q,s,s,s,s,q,q,b,q/*
)(format t /* a /* a */);}
```
Intentionally blank first line.
[Answer]
# [Vyxal](https://github.com/Vyxal/Vyxal) `D`, 70 bytes/ [Python 3](https://docs.python.org/3/), 77 bytes
```
a="`q‛:Ė+34Cp‛a=print('a=%r;exec(a[13:])#\\140:Ė'%a)";exec(a[13:])#`:Ė
```
Vyxal : [Try it Online!](https://vyxal.pythonanywhere.com/#WyJEIiwiIiwiYT1cImBx4oCbOsSWKzM0Q3DigJthPXByaW50KCdhPSVyO2V4ZWMoYVsxMzpdKSNcXFxcMTQwOsSWJyVhKVwiO2V4ZWMoYVsxMzpdKSNgOsSWIiwiIiwiIl0=)
```
a="`q‛:Ė+34Cp‛a=print('a=%r;exec(a[13:])#\\140:Ė'%a)";exec(a[13:])#`:Ė
```
Python : [Try it online!](https://tio.run/##K6gsycjPM/7/P9FWKaHwUcNsqyPTtI1NnAuAzETbgqLMvBIN9URb1SLr1IrUZI3EaENjq1hN5ZgYQxMDoFJ11URNJVSpBKDw//8A "Python 3 – Try It Online")
The difference beetween the number of bytes is due to the fact that vyxal and python doesn't use the same charset
## Explanation :
* Vyxal
```
a="                            # do nothing revelent here
   `q‛:Ė+                 `:Ė  # structure for a quine
         34Cp‛a=p              # prepend `a="` to the string
                 rint          # do stuff that somehow push 0 to the stack
                     (         # for loop over 0 (do nothing)
                        #      # comment and implicily close the loop
                               # implicit output
```
* Python
The quine is a variation of `a="print('a=%r;exec(a)'%a)";exec(a)`
[Answer]
# 05AB1E/2sable, 14 bytes, non-competing
```
0"D34çý"D34çý
```
[Try it online! (05AB1E)](http://05ab1e.tryitonline.net/#code=MCJEMzTDp8O9IkQzNMOnw70K&input=)
[Try it online! (2sable)](http://2sable.tryitonline.net/#code=MCJEMzTDp8O9IkQzNMOnw70K&input=)
2sable is derived from 05AB1E and is similar, but has major differences.
Trailing newline.
[Answer]
# C/TCL, 337 bytes
```
#define set char*f=
#define F
#define proc main(){
set F "#define set char*f=
#define F
#define proc main(){
set F %c%s%c;
proc /* {} {}
puts -nonewline %cformat %cF 34 %cF 34 91 36 36]
set a {*/printf(f,34,f,34,91,36,36);}
";
proc /* {} {}
puts -nonewline [format $F 34 $F 34 91 36 36]
set a {*/printf(f,34,f,34,91,36,36);}
```
[Answer]
# C/Vim 4.0, 1636 bytes
Contains control characters.
```
map () {}/*
map g ;data0df"f"cf"
f"cf"
f"D2kyyP;g6k2dd4x5jA"JxA","JxA","jyyPkJxA"jok;g2kdd4xkJx3jdd
map ;g O"vdldd0i# 0# 1# 2# 3# 4# 5# #0lx2lx2lx2lx2lx2lx2lx:s/##/#/g
o:s//"/gk0y2lj02lp"addk@ao:s//\\/gk0ly2lj02lp"addk@ao:s///gk04ly2lj02lp05l"vp"addk@ao:s///gk05ly2lj02lp05l"vp"vp"addk@ao:s//
/gk06ly2lj02lp05l"vp"vp"vp"addk@ao:s//
/gk02ly2lj02lp05l"vp"addk@a
unmap ()
map ;data o*/ char*g[]={"map () {}/*#2map g ;data0df#0f#0cf#0#5#3f#0cf#0#5#3f#0D2kyyP;g6k2dd4x5jA#0#3JxA#0,#0#3JxA#0,#0#3jyyPkJxA#0#3jo#3k;g2kdd4xkJx3jdd#2map ;g O#4#4#4#4#3#0vdldd0i## 0## 1## 2## 3## 4## 5## ###30lx2lx2lx2lx2lx2lx2lx:s/####/##/g#5o:s//#0/g#3k0y2lj02lp#0addk@ao:s//#1#1/g#3k0ly2lj02lp#0addk@ao:s//#4#4#3/g#3k04ly2lj02lp05l#0vp#0addk@ao:s///g#3k05ly2lj02lp05l#0vp#0vp#0addk@ao:s//#4#4#5/g#3k06ly2lj02lp05l#0vp#0vp#0vp#0addk@ao:s//#4#4#5/g#3k02ly2lj02lp05l#0vp#0addk@a#2unmap ()#2#2map ;data o*/ char*g[]={","#A#0#a#0,#0#b#0,#0#c#0#C#2","}; /*#3#2#2#0*/  print(char*s){char*t=s,c,d;while(c=*t++)if(c==35){c=*t++;if(c==35)putchar(c);else if(c==48)putchar(34);else if(c==49)putchar(92);else if(c==50)printf(#0#1n#0);else if(c==51)putchar(27);else if(c==52)putchar(22);else if(c==53)putchar(13);else if(c>64&&c<91)print(g[c-65]);else printf(g[c-97]);}else putchar(c);}  main(){print(g[1]);}"}; /*
"*/  print(char*s){char*t=s,c,d;while(c=*t++)if(c==35){c=*t++;if(c==35)putchar(c);else if(c==48)putchar(34);else if(c==49)putchar(92);else if(c==50)printf("\n");else if(c==51)putchar(27);else if(c==52)putchar(22);else if(c==53)putchar(13);else if(c>64&&c<91)print(g[c-65]);else printf(g[c-97]);}else putchar(c);}  main(){print(g[1]);}
```
Your Vim needs to have the following set:
```
set noai
set wm=0
set nosi
set tw=0
set nogdefault
```
[Answer]
## Perl/Javascript (SpiderMonkey), 106 bytes
```
$_='$q=+[]?h^O:unescape("%27");print("$_="+$q+$_+$q+";eval($_)"||(q($_),"=$q$_$q;",q(eval($_))))';eval($_)
```
[Try the Perl online!](https://tio.run/##K0gtyjH9/18l3lZdpdBWOzrWPiPO36o0L7U4ObEgVUNJ1chcSdO6oCgzr0RDCahKSVulUFslHkQqWaeWJeZoqMRrKtXUaBSCGDpKtiqFKvEqhdZKOoUaMGkgUIer/f8fAA "Perl 5 – Try It Online")
[Try the JavaScript online!](https://tio.run/##y0osSyxOLsosKNEtLshMSS3Kzc/LTq38/18l3lZdpdBWOzrWPiPO36o0L7U4ObEgVUNJ1chcSdO6oCgzr0RDCahKSVulUFslHkQqWaeWJeZoqMRrKtXUaBSCGDpKtiqFKvEqhdZKOoUaMGkgUIer/f8fAA "JavaScript (SpiderMonkey) – Try It Online")
### Explanation
The quine data is stored in `$_` in both languages and then `eval`ed, which is pretty much standard procedure in Perl. I chose SpiderMonkey on TIO as it has a `print` function, but this could easily be ported to browser for + 20 bytes (add `eval("print=alert");` to the beginning of `$_`s definition).
Perl sees the data stored in `$_` and `eval`s it as usual. Since `+[]` is truthy in Perl,`'` is stored in `$q` via the stringwise-XOR of `h` and `O`. The final trick is in the call to `print` where the first part for JavaScript uses `+`, which in Perl treats all items as numbers, and adds up to `0`, then we use the `||` operator to return what we actually want `(q($_),"=$q$_$q;",q(eval($_)))` which is equivalent to `"\$_=$q$_$q;eval(\$_)"`.
In JavaScript, `+[]` returns `0`, so we call `unescape("%27")` to store `'` in `$q` (unfortunately, `atob` doesm't exist in SpirderMonkey...). In the call to `print`, since `+` is the concatenation operator in JavaScript, the first block builds the desired output and the second part after the `||` is ignored.
**Thanks to [Patrick Roberts' comment](https://codegolf.stackexchange.com/q/37464/9365#comment-299961) for the `unescape` trick!**
---
## Perl/JavaScript (Browser), 108 bytes
```
$_='eval("q=_=>_+``;printf=console.log");printf(q`$_=%s%s%s;eval($_)`,$q=+[]?h^O:atob("Jw"),$_,$q)';eval($_)
```
[Try the Perl online!](https://tio.run/##K0gtyjH9/18l3lY9tSwxR0Op0Dbe1i5eOyHBuqAoM68kzTY5P684PydVLyc/XUkTKqhRmADUoVoMgtZgfSrxmgk6KoW22tGx9hlx/laJJflJGkpe5UqaOirxQAlNdbi6//8B "Perl 5 – Try It Online")
```
$_='eval("q=_=>_+``;printf=console.log");printf(q`$_=%s%s%s;eval($_)`,$q=+[]?h^O:atob("Jw"),$_,$q)';eval($_)
```
### Explanation
We store the quine data in `$_` in both languages and then `eval` it, which is pretty much standard procedure in Perl.
Perl sees the data stored in `$_` and `eval`s it as usual. The `eval` within `$_` is executed and fails to parse, but since it's `eval`, doesn't error. `printf` is then called, with a single quoted string `q()`, with ``` as the delimter, as just using ``` would result in commands being executed in shell, then for the first use of `$q`, since `+[]` is truthy in Perl, `'` is stored in `$q` via stringwise-XOR of `h` and `O`.
In JavaScript, the `eval` block within `$_` sets up a function `q`, that `return`s its argument as a `String` and aliases `console.log` to `printf`, since `console.log` formats string like `printf` in Perl. When `printf` is called `+[]` returns `0`, so we call `atob` to decode `'` and store in `$q`.
[Answer]
# [Perl 5](https://www.perl.org/)/[Ruby](https://www.ruby-lang.org/)/[PHP](https://php.net/)/JavaScript (Browser), 153 bytes
```
$_='$z=0?"$&".next: 0..a||eval("printf=console.log;atob`JCc`");printf("%s_=%s%s%s;eval(%s_);",$d=$z[0]?$z[0]:h^L,$q=$z[1]?$z[1]:h^O,$_,$q,$d);';eval($_);
```
[Try the Perl online!](https://tio.run/##K0gtyjH9/18l3lbdoKYmtSwxR0OpoCgzryTNNjk/rzg/J1UvJz9dSdMaIqihpFocb6taDILWYNVAvqaSjkqSrYG9hrGZpl5yRpGVgnZ0rH1GnI@ClUJiSX6ShpKXo5KmjkohWI0lihp/hJpykJp4oDKgaZrqENNV4jX//wcA "Perl 5 – Try It Online")
[Try the Ruby online!](https://tio.run/##KypNqvz/XyXeVt2gpia1LDFHQ6mgKDOvJM02OT@vOD8nVS8nP11J0xoiqKGkWhxvq1oMgtZg1UC@ppKOSpKtgb2GsZmmXnJGkZWCdnSsfUacj4KVQmJJfpKGkpejkqaOSiFYjSWKGn@EmnKQmnigMqBpmuoQ01XiNf//BwA "Ruby – Try It Online")
[Try the PHP online!](https://tio.run/##K8go@G9jXwAkVeJt1VWqbA3slVTUlPTyUitKrBQM9PQSa2pSyxJzNJQKijLzStJsk/PzivNzUvVy8tOtE0vykxK8nJMTlDStIdIaSqrF8baqxSBoDdYH5GtaK@mopNiqVEUbxNqDSauMOB8dlUKQkCFYyBAk5K@jEg8UBarVtFaH6FYBav7/HwA "PHP – Try It Online")
```
$_='$z=0?"$&".next: 0..a||eval("printf=console.log;atob`JCc`");printf("%s_=%s%s%s;eval(%s_);",$d=$z[0]?$z[0]:h^L,$q=$z[1]?$z[1]:h^O,$_,$q,$d);';eval($_);
```
[Answer]
# C/dc, 152 bytes
```
z1d//[[z1d//]P91PP93P[dx]Pq
;main(){char*a="z1d//[[z1d//]P91PP93P[dx]Pq%c;main(){char*a=%c%s%c;printf(a,10,34,a,34);}//]dx";printf(a,10,34,a,34);}//]dx
```
Taking advantage of comments, yeah!
]


[Question]
      [
Inspired by the title of [the *Toggle some bits and get a square* challenge](https://codegolf.stackexchange.com/questions/170281/toggle-some-bits-and-get-a-square).
In that challenge you output how many bits should be toggled, in order for the base-10 representation of the binary to become a square number.
## Challenge:
In this challenge, you'll be given a bit-matrix \$M\$ and an integer \$n\$ as inputs.
Output the edge-size of the largest square you can make by toggling at most \$n\$ bits in the grid. A square is defined as having a border of `1`s, with an irrelevant inner body.
E.g., these all contain valid squares of size 4x4, highlighted below with `X`:
(for the third example, more than one 4x4 square is possible)
```
1111  1111  11111111  010110
1001  1011  11111111  001111
1001  1101  11111111  101011
1111  1111  11111111  111001
                      011111
XXXX  XXXX  XXXX1111  010110
X00X  X01X  X11X1111  00XXXX
X00X  X10X  X11X1111  10X01X
XXXX  XXXX  XXXX1111  11X00X
                      01XXXX
```
**Example:**
So let's say the inputs are \$n=4\$ and \$M=\$
```
010110
001011
101010
111001
011110
```
You could toggle these three bits (highlighted as `T`):
```
010110
001T11
10101T
111001
01111T
```
to get the 4x4 square of the fourth example above. So the output is `4`.
## Challenge rules:
* You can take the input-grid in any reasonable format. Can be a matrix of integers; matrix of booleans; list of strings; list of integers for which their binary representation (with leading 0s) is the binary grid; etc.
* You toggle at most \$n\$ bits, not exactly \$n\$ bits.
* The input-matrix \$M\$ is not guaranteed to be a square, but it is guaranteed to be a (non-empty) rectangle.
* The input-integer \$n\$ is guaranteed to be non-negative (\$n\geq0\$).
## General Rules:
* This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'"), so the shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
* [Standard rules apply](https://codegolf.meta.stackexchange.com/questions/2419/default-for-code-golf-program-function-or-snippet/2422#2422) for your answer with [default I/O rules](https://codegolf.meta.stackexchange.com/questions/2447/default-for-code-golf-input-output-methods/), so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
* [Default Loopholes](https://codegolf.meta.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden.
* If possible, please add a link with a test for your code (e.g. [TIO](https://tio.run/#)).
* Also, adding an explanation for your answer is highly recommended.
## Test Cases:
| Inputs: | Output: |
| --- | --- |
| \$n\$=`4` and \$M\$=
```
010110001011101010111001011110
```
 | 4 |
| \$n\$=`8` and \$M\$=
```
0010101010110111001001001
```
 | 4 |
| \$n\$=`0` and \$M\$=
```
000000000000
```
 | 0 |
| \$n\$=`0` and \$M\$=
```
111111
```
 | 2 |
| \$n\$=`1` and \$M\$=
```
101010101
```
 | 1 |
| \$n\$=`1000` and \$M\$=
```
100010010010100101100011110110110101010010101001101011
```
 | 6 |

[Answer]
# JavaScript (ES6), 139 bytes
Expects `(n)(matrix)`.
```
n=>m=>m.map(W=h=(X,w,k,Y)=>m.map((r,y)=>r.map((v,x)=>k?h(x,w,q=t=0,y):(x-X)%w&&(y-Y)%w||x<X|x>X+w|y<Y|y>Y+w||++q<w*4|(t+=!v)>n?0:W=w+1)))|W
```
[Try it online!](https://tio.run/##VU9Nb4IwGL73V3Qmc@3Apk08LM7iaTvu4kGIemAIyoSiBQWy7rezfmiWJW3f530@3rZf8TWuE5mfmomodumQ8UHwoNSLlPEJrfiBo9Bv/aMf4TuJpN/rRrrm6ne6OS4OqNO@M2841fIMdZMQP7bjMeonkQZKdfNQdUHotaqfR6oPIo2U553n7fNUocbjD1cciAWdrXjrMYyxWg0yPV9ymaKnrH7CRKbx7j0v0mUvEkQxaaplI3OxR5jUpyJv0GgjNmKESVbJtzg5oBryAH4DCIu0gWsofEgIKeEWclj/RUb4VVuEJj1hUKmR@6nNr3Wm3tr@41J@phJbf1KJuipSUlR7lCGBUWn4HzxMAWWUMQqorYCZQgHTFGVaMwCAFyeDu@icBlPrAyb/fwM7xG5gxwIbNWZmdHPc89QNY45k7gJ3j8vdopTeHsh@AQ "JavaScript (Node.js) – Try It Online")
### Commented
```
n =>                    // n = max. number of times we can toggle bits
m =>                    // m[] = binary matrix
m.map(W =               // initialize W to a zero'ish value
h = (X, w, k, Y) =>     // for each entry in m[], using a recursive callback h:
  m.map((r, y) =>       //   for each row r[] at index y in m[]:
    r.map((v, x) =>     //     for each value v at index x in r[]:
      k ?               //       if this is the first pass:
        h(              //         do a recursive call:
          x,            //           set X = x
          w,            //           pass w unchanged
          q = t = 0,    //           set k = q = t = 0
          y             //           set Y = y
        )               //         end of recursive call
      :                 //       else (2nd pass):
        (x - X) % w &&  //         do nothing if we're not located on the grid
        (y - Y) % w ||  //         of width w
        x < X |         //         or x is too low
        x > X + w |     //         or x is too high
        y < Y |         //         or y is too low
        y > Y + w       //         or y is too high
        ||              //         otherwise:
          ++q < w * 4 | //           increment q
          (t += !v) > n //           increment t if v = 0
          ?             //           if q < w * 4 (not a complete square)
                        //           or t > n (too many bits must be toggled):
            0           //             do nothing
          :             //           else:
            W = w + 1   //             success: update W
    )                   //     end of map()
  )                     //   end of map()
) | W                   // end of map(); return W
```
[Answer]
# [MATL](https://github.com/lmendo/MATL), 30 bytes
```
xZyP:"0&G@qWQB&+gZ++7Mz<m@*vX>
```
It uses convolution \o/
Inputs are `n`, then `M`.
[Try it online!](https://tio.run/##y00syfn/vyKqMsBKyUDN3aEwPNBJTTs9Slvb3LfKJtdBqyzC7v9/E65oAwVDBRAGktZABpxrDWUYQGQMIUpAXGuoerBALAA "MATL – Try It Online") Or [verify all test cases](https://tio.run/##y00syfmf8L8iqjLASslAzd2hMDzQSU07PUpb29y3yibXQasswu5/rEtURch/E65oAwVDBRAGktZABpxrDWUYQGQMIUpAXGuoerBALJcFyAyoSmt0LUhGGcCsgHJiuQwgOqH2olFgaUOYdkOQekOQAMIWqAuB4gYGBhApTFtgyuAORCgzRHIisnuR/IFsD8zziGAxjAUA "MATL – Try It Online").
### Explanation
```
x        % Implicit input: n. Delete
Zy       % Implicit input: M. Size as a length-two vector, [R, C]
P        % Sort. Gives [S, L], where S = min(R, C) is the smallest dimension of A
:        % Range from 1 to the first entry of the vector, that is, A
"        % For each k in [1, 2, ... , A]
  0      %   Push 0
  &G     %   Push the two inputs again: n, then M
  @      %   Push k
  qWQB   %   Subtract 1, 2 raised to that, add 1, binary: gives [1 0 0 ··· 0 1] of
         %   length k
  &+g    %   2D array of pairwise additions. Convert to logical. This gives a binary
         %   k×k array with a frame of ones: [1 1 ··· 1 1;
         %                                    1 0 ··· 0 1;
         %                                    ··· ··· ···
         %                                    1 0 ··· 0 1;
         %                                    1 1 ··· 1 1]
  Z+     %   2D convolution with M, maintaining size. This counts the number of ones
         %   in M along all sliding frames of the above form. The result is a 2D array
  +      %   Add the above with n, element-wise.
  7M     %   Push the 2D array defining the frame again. Number of nonzeros. This
         %   gives the frame "length", that is, the number of ones (which is 4*(k-1))
  <      %   Less than?, element-wise. An entry equal to 0 indicates that a frame
         %   exists such that the number of ones in M along that frame plus n is at
         %   least the frame length
  m      %   Ismember. This checks if 0 is indeed present in the above result
  @*     %   Multiply the above by k. This will give either 0 or k
  vX>    %   Concatenate stack contents, then maximum. This computes a cumulative
         %   maximum of the results for all k (each result being either 0 or k)
         % End (implicit). Display (implicit)
```
[Answer]
# [JavaScript (Node.js)](https://nodejs.org), 133 bytes
```
n=>m=>m.map(W=h=(X,w,Y,t)=>m.every((r,y)=>[...r,0].every((v,x)=>t?x%w&&y%w||x>w|y>w||(t+=1-(m[y+Y]||0)[x+X]):h(x,w,y,~n)?W=w+1:1)))|W
```
[Try it online!](https://tio.run/##VU/LbsIwELz7KywkwFaMZUs9VFSGU3vshQOgNIc0OJAqcahjSKKm/fXUD1BVyevdnZ3Zx0d6TZtMF2ezUPVBjrkYlVhV9tEqPaOtOAm0Iy3ZE4MdKK9S9whp0ts0ppRqwpI7eiWdRc26m7azWT9th6FbtUNvbUAmEnyBqriP9skwMBx30S7ByxPqbPee/Ci83oo24kuOMR62o5afl0JLNM@bOaZapoeXopSbXmWIYWrqjdGFOiJMm3NZGDR5U29qgmle6@c0O6EGihX8AhCW0sAYKgLtrhVMoIDNn2SCnyxFWTBSLqpsFA73endfk/j89VK9S409P6tVU5eSlvUR5UhhVDn8G48PgHHGOQPMe8CdY4BbiHFbcwEAj6EM7sXAdDHzPOD0/w34Jt6Abwu81JG5q7vvrmehGQ8gDwPCnKC7SRm7Lch/AQ "JavaScript (Node.js) – Try It Online")
# [JavaScript (Node.js)](https://nodejs.org), 134 bytes
```
n=>m=>m.map(W=h=(X,w,k,Y)=>m.map((r,y)=>r.map((v,x)=>k?h(x,w,q=t=0,y):x%w&&(y-Y)%w||x>w|y<Y|y>Y+w||++q<w*4|(t+=!r[x+X])>n?0:W=w+1)))|W
```
[Try it online!](https://tio.run/##VU9Nb8IgGL7zK5iJCmslkHhYnNTTdtzFgzbqoatUO1uqtNo26357x4dmWQK87/P1Al/RLSpjlZ6riSz2ok94L3mQ60Xy6IxW/MjR2q/9kx/iB4mU32qgHLj5jQanxRE12nfhFadanjXDejRC7STEw7rrmqDu2nnYtUHoaeh5l3n9PO1Q5fEntWm89Q4HckFnK157DGPcrXolLtdUCTROyjEmSkT79zQTy1bGiGJSFctKpfKAMCnPWVqhwVZu5QCTpFBvUXxEJeQB/AYQZqKCGyh9SAjJ4Q5yWP5FBvhVW6QmPWm6XHfukza/0ZlyZ/HHNf8UClt/XMiyyATJigNKkMQoN/wP7qeAMsoYBdRWwEyhgGmKMq2ZBoAXJ4OH6Jymp9YHTP7/BnaI3cCOBTZqzMzo5njkqRvGHMncBe4el7tHKb0/kP0C "JavaScript (Node.js) – Try It Online")
Modified from Arnauld's
# [JavaScript (Node.js)](https://nodejs.org), 156 bytes
```
M=>n=>M.map((_,i)=>M.map((N,y)=>N.map((c,x)=>R=M.map((_,j)=>W-=j<i&&N[x+j]+M[y+i][x-~j]+M[y-~j][x]+M[y+j][x+i],W=4*i+!i*!c)&&W<=n?i+1:R),M.push([])),R=0)&&R
```
[Try it online!](https://tio.run/##fZG9boMwFIX3vkUWZMcG2VKGqIqTLRsMLAyWVSEStUYpoNBGZMmr02t@HKNAhcB8@NxzL8d5ekvr7KqrH78oT@f2KNpQ7AuxD4PvtELog2psIaJ3gKiHjDYAsbDCHDDxRb7TnhfJhuSKhPJOtJKN/@jBrLLpv5s32KSJ2Kw1Wen1KsOel@xEcdCEv8eYhkH1W38hqTCmsWCwG7dZWdTl5Rxcyk90RFIyyqm54akokGUgbol11KkMd0o@XEwpjDYYv71aD@WD3DVyWzDbfLQHw@2C4Tjl6wpFbKaI2068d14SLTpYez63afp394JgksAY6r9zzEViS5@RPpXcDXUSsRv@ZAB7jtw5cfMHjJm52j8 "JavaScript (Node.js) – Try It Online")
I don't know what I'm doing...
```
M=>n=> // Unupdated
M.map((_,i)=>
  M.map((N,y)=>N&&
    N.map((c,x)=>
      R=M.map((_,j)=>
        W-=j<i&&
          N[x+j]+
          M[y+i][x-~j]+
          M[y-~j][x]+
          M[y+j][x+i],
        W=4*i)|i|c|n&&    // When i=0
                          // Special consider:
                          // Here is 1, or
                          // n>0
        W<=n?i+1:R),M.push(0)),R=0)&&R
                 // So Z[y+i] isn't undefined
```
[Answer]
# [Pyth](https://github.com/isaacg1/pyth), 63 bytes
```
KEVUQVUhQVhS,-lQN-lhQHIgKsm!|*F*V-Rbdd@@Q+Nhd+Hed^Uhb2=eS,Zhb;Z
```
[Try it online!](https://tio.run/##K6gsyfj/39s1LDQwLDQjMCwjWEc3J9BPNycj0MMz3bs4V7FGy00rTDcoKSXFwSFQ2y8jRdsjNSUuNCPJyDY1WCcqI8k66v//6GgDHUMdEAaSsTpAHpwP5BnCeQZgHlgViA9WaQiFBrGxXCYA "Pyth – Try It Online")
Expects array of arrays of booleans and \$n\$ in that order.
### Explanation
```
                                                                   # implicitly assign Q = eval(input())
KE                                                                 # assign K = eval(input())
  VUQ                                                              # for N in range(len(Q)):
     VUhQ                                                          #   for H in range(len(Q[0])):
         VhS,-lQN-lhQH                                             #     for b in range(1+max(len(Q)-N, len(Q[0])-H)):
                          m                      ^Uhb2             #       map range(b+1) x range(b+1) to lambda d  (look at coordinates in a square of size b+1)
                           !|                                      #         neither of the following are true
                             *F*V-Rbdd                             #         d[0]*d[1]*(d[0]-b)*(d[1]-b)  (coordinates are in the middle of the square)
                                      @@Q+Nhd+Hed                  #         Q[N+d[0]][H+d[1]]  (coordinates are already a 1 in Q)
                      IgKs                                         #       if K >= (the sum of this map):
                                                      =eS,Zhb      #         Z = max(Z, b+1)
                                                             ;Z    # after all loops complete, output Z
```
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~27~~ 25 [bytes](https://github.com/DennisMitchell/jelly/wiki/Code-page)
```
¬ẆZṡLƊ€Ẏ.ị$€JṖḊƊ¦FS>ʋÐḟẈṀ
```
A dyadic Link that accepts the matrix, \$M\$, on the left and the maximal toggle count, \$n\$, on the right and yields the side length of the largest attainable square.
**[Try it online!](https://tio.run/##y0rNyan8///Qmoe72qIe7lzoc6zrUROQ06f3cHe3CpDp9XDntIc7uo51HVrmFmx3qvvwhIc75j/c1fFwZ8P///@jow11DMAQSMdy6USDGQgunKNjiOCCBKBcQwgHptgQWTEWo6ACyFywUbH/LQE "Jelly – Try It Online")** Or see the [test-suite](https://tio.run/##y0rNyan8///Qmoe72qIe7lzoc6zrUROQ06f3cHe3CpDp9XDntIc7uo51HVrmFmx3qvvwhIc75j/c1fFwZ8P/o5Mf7lz8qHHfoW2Htj3cvQWo@tDWhztXhR1e7hAG5ACR5v//BoYGhoYGXAZgmssQRBlwGQKFDAy5gCIgORMuiDQXTBKiEsQ2AKuzACkwQMVcIEPAGMSEaAbThiAuQrMBxCRDiKAhxHSIJRBNUH0GBlDXQVQCAA "Jelly – Try It Online").
### How?
Toggles all bits of \$M\$ and extracts all possible square sub-matrices. Filters out any which have more than \$n\$ ones in their border, and then gets the length of the longest remaining one (or zero).
```
¬ẆZṡLƊ€Ẏ.ị$€JṖḊƊ¦FS>ʋÐḟẈṀ - Link: list of lists of 1s and 0s; M, integer, n
¬                         - logical NOT (M) -> toggle all bits of M
 Ẇ                        - get all contiguous sublists of rows of that
      €                   - for each (sublist, s, of rows):
     Ɗ                    -   last three links as a monad - f(s):
  Z                       -     transpose (s)
    L                     -     length (s)
   ṡ                      -     all sublists of (transposed s) of length (length (s))
                              -> all full height square sub-matrices from s
       Ẏ                  - tighten to a list of all square-submatrices
                     Ðḟ   - filter discard those for which:
                    ʋ     -   last four links as a dyad - f(sub-matrix, n)
           €    ¦         -     sparse application...
               Ɗ          -     ...to indices: last three links as a monad - f(sub-matrix):
            J             -                      range of length
             Ṗ            -                      pop
              Ḋ           -                      dequeue -> [2,3,...,length-1]
          $               -     ...action: last two links as a monad - f(sub-matrix):
        .                 -                  0.5
         ị                -                  index into (sub-matrix) -> last and first entries
                 F        -     flatten
                  S       -     sum
                   >      -     is greater than (n)?
                       Ẉ  - length of each (remaining sub-matrix)
                        Ṁ - maximum (or 0 if empty)
```
---
Note: the second `€` is necessary, even though all of the test cases pass without it (e.g. [this](https://tio.run/##y0rNyan8///Qmoe72qIe7lzoc6zrUROQ06f3cHe3itfDndMe7ug61nVomVuw3anuwxMe7pj/cFfHw50N////j4421DHQMYzl0kFlGMRyxf43AgA) should return `2` not `3`).
[Answer]
# [Charcoal](https://github.com/somebody1234/Charcoal), 61 bytes
```
ＮθＷＳ⊞υι≔ＬυζＷ⬤υ⬤κ›⁻∨×⁴⊖ζ¹θΣ⭆υ⎇№…λ⁺λζπ✂ξν⁺νζ∨∨⁼πλ⁼π⁺λ⊖ζ⊖ζω≦⊖ζＩζ
```
[Try it online!](https://tio.run/##bVDbSgMxEH3PV@RxAhES6FufShURrC62PxDXYRvMTndzsdqfXyfdSkUMGSY5Z86ZYdq9i@3BhWl6oKHkp9K/YoRRLcVx7wNKOMPbHD11oJRsStpD0dJzxSol3xE8InWZQaXl6apbhVDranrX8j6iy2y88VQSPEfY@R4TLLS8xTZij5TxDU6KPSzHyLEtPcx9N26oVjuM5OIXrA@FMrw46hCClk1gx1B7s2iowuBbhE8t6UJSJbXkrnzvxuJCgkHLwNj192PzZx71H3JU85E82WUJv4rmNTQ8eYa1S7mKltO0EMYaa40w5yxsTUZYhoxlrj7EdPMRvgE "Charcoal – Try It Online") Link is to verbose version of code. Takes `n` as the first input and then the binary matrix `M` as a list of newline-terminated strings. Explanation:
```
Ｎθ
```
Input `n`.
```
ＷＳ⊞υι
```
Input `M`.
```
≔Ｌυζ
```
Start with the height of `M` as the current square size.
```
Ｗ⬤υ⬤κ›⁻∨×⁴⊖ζ¹θΣ⭆υ⎇№…λ⁺λζπ✂ξν⁺νζ∨∨⁼πλ⁼π⁺λ⊖ζ⊖ζω
```
For each possible cell of `M`, try to slice a square of the current size out of `M`, count the number of `1`s on its border, and while none of the candidate squares have enough `1`s...
```
≦⊖ζ
```
... decrement the square size.
```
Ｉζ
```
Output the final square size.
[Answer]
# [PARI/GP](https://pari.math.u-bordeaux.fr), 116 bytes
```
f(a,n)=for(k=l=0,min(#a,#a~),matrix(#a~-k,#a-k,i,j,sum(s=0,k,sum(t=0,k,!(s*t*(k-s)*(k-t)+a[i+s,j+t])))<=n)&&l=k+1);l
```
[Attempt This Online!](https://ato.pxeger.com/run?1=ZVFBasMwEKTXvkJJIGjjNUjQQ0BxP-KKIgouimTX2Aq0l3ykl1xK39S-prIkywk9aJnZ3dlZSZ_fvRr082t_uXydXFPuf1xDFXZQNW8DNZWtGLa6oxuFG3UGbJUb9Lun59L4jA8ajzieWjr6ThOQC2hFx53bUVOOMEUHhap1MeKxcBIADlUH262tTMFB2Oj9e9eqvrcfVJHykfSD7pyH64msyYuyljZIFACSuq4ZcpyOj4JhZoJnzASP9YmJ2Bu4RPIgpyFZJ241yySW5ifsVfusjL430ddYqPM0gQfNnMtOcUuf5bnyzyt1zRsuPXzZ8Wrfp_vlHlce6fbLqwRXxpiUEF99_vk_)
[Answer]
# [05AB1E](https://github.com/Adriandmen/05AB1E/wiki/Commands), 40 [bytes](https://github.com/Adriandmen/05AB1E/wiki/Codepage)
```
U˜āR.Δ…€üÿD'øý.V€`ε4Fćˆíø}¯˜_OXs@´}à}Dd*
```
Since there isn't a 05AB1E answer yet, I'll just create my own.
Inputs in the order \$n,M\$.
[Try it online](https://tio.run/##yy9OTMpM/f8/9PScI41BeuemPGpY9qhpzeE9h/e7qB/ecXivXhiQm3Buq4nbkfbTbYfXHt5Re2j96Tnx/hHFDoe21B5eUOuSovX/vwVXdLSBjoGOIQjH6kRDWToGQLYhlG0IZhvAxSFqQOpjAQ) or [verify all test cases](https://tio.run/##yy9OTMpM/V9WmVCs5JlXUFpSbKWQZ6tkb6@kkJiXouBrq6TjdWi3DpeSf2kJUNZKQcm@MuHQyuL/oafnHGkM0js35VHDskdNaw7vObzfRf3wjsN7D60r1gsDiiSc22ridqT9dNvhtYd31B5af3pOvH9EscOhLbWHF9S6pGj91zm0zf5/dLSJTnS0gY6hDggDyVgdIA/OB/IM4TwDMA@sCsQHqzSEQoPY2FgdhWgLsGFQDVAFyFqRDTWAWwczEGyEAdQImEswabgyQ7hphjDdhmBhJMthPoBKGxgYQFVgcQBcNcIDCJWGyF5A8RCyV1HshIeTIVKIAgEA).
**Explanation:**
```
U                  # Pop and store the first (implicit) input-integer in variable `X`
˜                  # Flatten the second (implicit) input-matrix
 ā                 # Push a list in the range [1,length]
  R                # Reverse it to [length,1]
   .Δ              # Pop and find the first value that's truthy for
                   # (or -1 if none are truthy):
     …€üÿD'øý.V€` '#  Get a list of all overlapping block of size y×y
                   #  (where `y` is the current integer):
     …€üÿ          #   Push string "€üÿ",
                   #   where `ÿ` is automatically replaced with the current integer
         D         #   Duplicate it
          'øý     '#   Join the two strings on the stack with "ø" delimiter
             .V    #   Evaluate and execute it as 05AB1E code:
      €            #    Map over each row of the (implicit) input-matrix
       üy          #     Get all overlapping lists of this row of size `y`†
         ø         #    Zip/transpose; swapping rows/columns
          €        #    Map over each list of lists
           üy      #     Get all overlapping lists of these row of size `y`†
             €`    #    Flatten this list of lists of blocks one level down
     ε4Fćˆíø}¯´˜   #  Leave just the borders of each y×y block:
     ε             #   Map over each block:
      4F           #    Inner loop 4 times:
        ć          #     Extract head; pop and push remainder-matrix and first row
                   #     separately to the stack
         ˆ         #     Pop and add this first row to the global array
          íø       #     Rotate the matrix once clockwise:
          í        #      Reverse each inner row
           ø       #      Zip/transpose; swapping rows/columns
       }¯          #    After the loop: push the global array
         ˜         #    Flatten it
          _        #    ==0 check (0 becomes 1; everything else becomes 0)
           O       #    Sum to get the amount of 0s in this block's borders
            X      #    Push the first input from variable `X`
             s@    #    Check amountOfZeros <= `X`
        ´          #    Empty the global array for the next iteration
     }à            #   After the map, do an `any` check by popping and pushing the max
   }Dd*            #  After the find first: fix a potential -1 to 0†:
    D              #   Duplicate the integer
     d             #   Pop the copy and do a non-negative check (1 if >=0; 0 if <0)
      *            #   Multiply the two together
                   # (after which the result is output implicitly)
```
We have to do the `}Dd*` instead of just lowering the `[length,1]` ranged list to `[length,0]`, because `ü0` would give an error.
]