[Question]
  [
Given (by any means) two different natural numbers (of any reasonable size), output (by any means) the square of their sum as in the examples below:
Given 4 and 3, output:
```
12 12 12 12  9  9  9
12 12 12 12  9  9  9
12 12 12 12  9  9  9
16 16 16 16 12 12 12
16 16 16 16 12 12 12
16 16 16 16 12 12 12
16 16 16 16 12 12 12
```
Given 1 and 3, output:
```
3 9 9 9
3 9 9 9
3 9 9 9
1 3 3 3
```
Whitespace may vary within reason but the columns must be left-aligned, right-aligned, or (pseudo-)centered.
A trailing newline is fine, but standard loopholes are not.
This is [code-golf](/questions/tagged/code-golf "show questions tagged 'code-golf'") so include a header like `# LanguageName, 123` in your answer, where the number is chars (bytes for languages that are not text-based). Packing code to large Unicode chars is not allowed.
---
**Bonus:** -3 if your code outputs just one square when one of the numbers is 0; e.g. given 0 and 3, output:
```
9 9 9
9 9 9
9 9 9
```
  
[Answer]
## J, 9 bytes - 3 = 6
```
#~@|.*/#~
```
Inspired by [@NBZ's APL answer](https://codegolf.stackexchange.com/a/61279/32014), golfed down by @randomra.
This defines a verb that takes in an array of numbers. It's used as follows:
```
   (#~@|.*/#~) 4 3
12 12 12 12  9  9  9
12 12 12 12  9  9  9
12 12 12 12  9  9  9
16 16 16 16 12 12 12
16 16 16 16 12 12 12
16 16 16 16 12 12 12
16 16 16 16 12 12 12
```
I also claim the 3-byte bonus, since an input of 0 produces sub-matrices of size zero:
```
   (#~@|.*/#~) 4 0
16 16 16 16
16 16 16 16
16 16 16 16
16 16 16 16
   (#~@|.*/#~) 0 3
9 9 9
9 9 9
9 9 9
```
## Explanation
J has a definite edge in this challenge.
In addition to eating array manipulation problems for breakfast, it prints 2D matrices in the correct format by default.
```
       #~  Replicate each number n in input n times
#~@|.      The same for reversed input
     */    Compute their multiplication table
```
[Answer]
# Octave, 45 bytes - 3 = 42
```
s=@(m,n)[a=ones(n,1)*n;b=ones(m,1)*m].*[b;a]'
```
### Explanation
This constructs two vectors (let's assume `m = 4` and `n = 3`):
`ones(n, 1)` constructs an array of ones of size `n x 1`, so multiplying the ones by `n` we get:
```
ones(n, 1) * n => [3 3 3]' (where ' is transpose... n x 1 is a column vector)
a = [3 3 3  4 4 4 4]'   %// a is a column vector
b = [4 4 4 4  3 3 3]    %// b is a row vector
```
Then the vectors are multiplied in an element-wise fashion, with automatic broadcast expansion so that the 7-element vectors produce a 7x7-element matrix:
```
    [3] .* [4 4 4 4 3 3 3]
    [3]
    [3]
    [4]
    [4]
    [4]
    [4]
```
For example, multiplication of the first row of `a` by `b` gives:
```
    [3] .* [4 4 4 4 3 3 3] = [12 12 12 12  9  9  9]
```
And similarly for the remaining rows of `a`.
### Output:
```
>> s(4,3)
ans =
   12   12   12   12    9    9    9
   12   12   12   12    9    9    9
   12   12   12   12    9    9    9
   16   16   16   16   12   12   12
   16   16   16   16   12   12   12
   16   16   16   16   12   12   12
   16   16   16   16   12   12   12
>> s(3,0)
ans =
   9   9   9
   9   9   9
   9   9   9
```
You can try it here on [ideone](http://ideone.com/Ube8ft)
[Answer]
# [Dyalog APL](http://goo.gl/9KrKoM), 10-3 = 7
Inspired\* by [this answer](https://codegolf.stackexchange.com/a/61221/43319) where the arguments are replicated and then used in a multiplication table:
```
⊖∘.×⍨(/⍨⎕)
```
`⎕` Issues a prompt (`⎕:`) and evaluates any expression entered then. (For security reasons, this doesn't work on [TryAPL](http://tryapl.org/) but it does work on [NGN/APL](http://ngn.github.io/apl/web/).)  
`/⍨` Replicates its argument itself times (`/⍨4 3` ​⇔ `3 3 3 4 4 4 4`)  
`∘.×⍨` Creates a multiplication table.  
`⊖` Flips upside down.
This happens to work on any length input (input is indented 6 spaces, output is at left margin):
```
      ⊖∘.×⍨(/⍨⎕)
⎕:
      ⍬      ⍝ Empty list (the square of nothing)
      ⊖∘.×⍨(/⍨⎕)
⎕:
      0      ⍝ 0​² = 0
      ⊖∘.×⍨(/⍨⎕)
⎕:
      0 1      ⍝ (0+1)​² = 1²
1
      ⊖∘.×⍨(/⍨⎕)
⎕:
      2 3      ⍝ (2+3)​² = 2² + 3²
6 6 9 9 9
6 6 9 9 9
6 6 9 9 9
4 4 6 6 6
4 4 6 6 6
      ⊖∘.×⍨(/⍨⎕)
⎕:
      1 2 3      ⍝ (1+2+3)​² = 1² + 2(1×2) + 2(1×3) + 2² + 2(2×3) + 3²
3 6 6 9 9 9
3 6 6 9 9 9
3 6 6 9 9 9
2 4 4 6 6 6
2 4 4 6 6 6
1 2 2 3 3 3
      ⊖∘.×⍨(/⍨⎕)
⎕:
      ⍳4    ⍝ Integers 1 through 4
4 8 8 12 12 12 16 16 16 16
4 8 8 12 12 12 16 16 16 16
4 8 8 12 12 12 16 16 16 16
4 8 8 12 12 12 16 16 16 16
3 6 6  9  9  9 12 12 12 12
3 6 6  9  9  9 12 12 12 12
3 6 6  9  9  9 12 12 12 12
2 4 4  6  6  6  8  8  8  8
2 4 4  6  6  6  8  8  8  8
1 2 2  3  3  3  4  4  4  4
```
---
\*Originally, I had a different solution in mind: Each rectangle is created separately by creating a multiplication table for each combination of the two arguments. Then the four squares are mended together vertically and horizontally. It looks like this:
```
,/⍪⌿⊖∘.(,⍴×)⍨⎕
```
`⎕` Prompt, as above.  
`,⍴×<` Combine (`,`) the args and use that to shape (`⍴`) a rectangle filled with their product (`×`).  
`∘.(`​…`)⍨` Create a table where each cell is whatever is specified in `(`​…`)`  
`⊖` Flip vertically.  
`⍪⌿` Combine cells vertically.  
`,/` Combine cells horizontally.
[Answer]
# R, 31 - 3 = 28
```
rev(b<-rep(a<-scan(),a))%*%t(b)
```
Explanation:
```
           a<-scan()            # take numeric input and store as vector a
    b<-rep(         ,a)         # repeat each numeric input by itself and store as vector b
rev(                   )        # the reverse of vector b
                        %*%     # matrix multiplication
                           t(b) # the transposed of vector b
```
This also works for more than two numbers. For example, the output for (5,3,2) looks like this:
```
      [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10]
 [1,]   10   10   10   10   10    6    6    6    4     4
 [2,]   10   10   10   10   10    6    6    6    4     4
 [3,]   15   15   15   15   15    9    9    9    6     6
 [4,]   15   15   15   15   15    9    9    9    6     6
 [5,]   15   15   15   15   15    9    9    9    6     6
 [6,]   25   25   25   25   25   15   15   15   10    10
 [7,]   25   25   25   25   25   15   15   15   10    10
 [8,]   25   25   25   25   25   15   15   15   10    10
 [9,]   25   25   25   25   25   15   15   15   10    10
[10,]   25   25   25   25   25   15   15   15   10    10
```
[Answer]
# Haskell, ~~153~~ 125 bytes - 3 = 122
```
(#)=replicate
d=length.show
y%x=unlines$(>>= \n->(1+d(x*x+y*y)-d n)#' '++show n)<$>x#(y#(x*y)++x#(x*x))++y#(y#(y*y)++x#(x*y))
```
Half of the code is for output formatting. It works for arbitrary large integers. Example output:
```
> putStrLn $ 4 % 3
12 12 12 12  9  9  9
12 12 12 12  9  9  9
12 12 12 12  9  9  9
16 16 16 16 12 12 12
16 16 16 16 12 12 12
16 16 16 16 12 12 12
16 16 16 16 12 12 12
> putStrLn $ 6 % 0
36 36 36 36 36 36
36 36 36 36 36 36
36 36 36 36 36 36
36 36 36 36 36 36
36 36 36 36 36 36
36 36 36 36 36 36
```
Sometimes there's an additional whitespace between the numbers, because I'm calculating the space needed based on `x*x+y*y` instead of `max (x*x) (y*y)`, e.g.
```
> putStrLn $ 2 % 3
  6  6  9  9  9
  6  6  9  9  9
  6  6  9  9  9
  4  4  6  6  6
  4  4  6  6  6
```
But it's at most one whitespace.
[Answer]
# Mathematica 56-3 = 53
*Update*:
I added a second method, of precisely the same code size, that uses a named function. It employs an `Array` rather than a `Table` but follows the same logic. (See below.)
**Method 1**
This makes a table of products, the factors of which depend on the row, column values. The pair of numbers is entered as a list of integers. Anonymous functions such as the following, are most useful if they are used only once in a program. Otherwise it makes more sense to use a named function.
```
Grid@Table[If[r>#2,#,#2]If[c>#,#2,#],{r,#+#2},{c,#+#2}]&
```
Each factor is an If-then statement:
* `If[r>#2,#,#2]` means, "If the row number is greater than the second input, use the first input as the factor, otherwise use the second input.
* `If[c>#,#2,#]` means, "If the column number is greater than the first input, use the second input as the factor, otherwise use the first input.
---
Example 1
```
 Grid@Table[If[r>#2,#,#2]If[c>#,#2,#],{r,#+#2},{c,#+#2}]&@@{5,3}
```
[![ex1](https://i.stack.imgur.com/gArTX.png)](https://i.stack.imgur.com/gArTX.png)
---
Example 2
```
Grid@Table[If[r>#2,#,#2]If[c>#,#2,#],{r,#+#2},{c,#+#2}]&@@{0,3}
```
[![ex2](https://i.stack.imgur.com/kbmC8.png)](https://i.stack.imgur.com/kbmC8.png)
---
**Method 2** (Also 56-3 = 53)
This works similarly to Method 1. But it requires less code when called. And the cells are addressable, unlike cells in a table. This method is better to use if the function will be used more than once.
```
a_~f~b_:=Grid@Array[If[#>a,a,b]If[#2>a,b,a]&,{a+b,a+b}]
```
The examples from above are produced by the following:
Ex 1:
```
f[4,3]
```
Ex 2:
```
f[0,3]
```
[Answer]
# Octave, 34 - 3 = 31
```
@(a)rot90(b=repelems(a,[1,2;a]))*b
```
**Examples:**
```
octave:1> f = @(a)rot90(b=repelems(a,[1,2;a]))*b;
octave:2> f([4,3])
ans =
   12   12   12   12    9    9    9
   12   12   12   12    9    9    9
   12   12   12   12    9    9    9
   16   16   16   16   12   12   12
   16   16   16   16   12   12   12
   16   16   16   16   12   12   12
   16   16   16   16   12   12   12
octave:3> f([0,3])
ans =
   9   9   9
   9   9   9
   9   9   9
```
[Answer]
# CJam, 27 bytes - 3 = 24
```
q:L~_]ze~_ff{*sL,2*Se[}W%N*
```
Takes input as a CJam style array. It uses a bit more spacing than necessary, but I think it's "within reason", and it's always properly right aligned.
[Test it here.](http://cjam.aditsu.net/#code=q%3AL~_%5Dze~_ff%7B*sL%2C2*Se%5B%7DW%25N*&input=%5B4%203%5D)
## Explanation
```
q:L    e# Read the input and store it in L.
~_     e# Evaluate the input, pushing [A B] onto the stack and duplicate it.
]z     e# Wrap both in an array and transpose it to get [[A A] [B B]].
e~     e# Run-length decode, getting A copies of A and B copies of B.
_ff{   e# Double map over each pair of entries in this new array...
  *s   e#   Multiply the two values.
  L,2* e#   Push twice the length of the input string.
  Se[  e#   Pad the result to this width with spaces (from the left).
}
W%     e# Reverse the resulting matrix to get the correct orientation.
N*     e# Join the rows with linefeed characters.
```
[Answer]
# C function (using glibc), 122 bytes - 3 = 119
Mostly straightforward implementation with 2 loops. I expect there are some golfing opportunities I have missed here:
```
f(n,m,x,y){for(x=0;x<n+m;x+=puts(""))for(y=0;y<n+m;y++)printf(" %*d",snprintf(0,0,"%d",n>m?n*n:m*m),(x<m?m:n)*(y<n?n:m));}
```
Inputs are passed in the first two parameters of the function, the other two are dummies. Columns are right-aligned.
Note glibc `puts()` always seems to return the number of bytes written including implicit trailing newline, which is what we need here. No guarantees this will work with any other libc.
In a full program:
```
f(n,m,x,y){for(x=0;x<n+m;x+=puts(""))for(y=0;y<n+m;y++)printf(" %*d",snprintf(0,0,"%d",n>m?n*n:m*m),(x<m?m:n)*(y<n?n:m));}
int main (int argc, char **argv) {
    if (argc == 3) {
        f(atoi(argv[1]),atoi(argv[2]));
    }
}
```
Compile as `gcc sqrbin.c -o sqrbin` (or `make sqrbin`). Warnings may safely be ignored.
### Example output:
```
$ ./sqrbin 4 3
 12 12 12 12  9  9  9
 12 12 12 12  9  9  9
 12 12 12 12  9  9  9
 16 16 16 16 12 12 12
 16 16 16 16 12 12 12
 16 16 16 16 12 12 12
 16 16 16 16 12 12 12
$ ./sqrbin 4 0
 16 16 16 16
 16 16 16 16
 16 16 16 16
 16 16 16 16
$ 
```
[Answer]
# Ruby, (133 - 3) = 130 bytes
```
s=1
a=ARGV.map{|e|s*=(e=e.to_i);[e]*e}.flatten
s=s.to_s.size
a.reverse.each{|i|a.each{|j|print (i*j).to_s.rjust(s).ljust(s+3)};puts}
```
## for 4,3
```
12   12   12   12    9    9    9   
12   12   12   12    9    9    9   
12   12   12   12    9    9    9   
16   16   16   16   12   12   12   
16   16   16   16   12   12   12   
16   16   16   16   12   12   12   
16   16   16   16   12   12   12
```
## for 1,3
```
3   9   9   9   
3   9   9   9   
3   9   9   9   
1   3   3   3
```
## for 0,3
```
9   9   9   
9   9   9   
9   9   9
```
[Answer]
# Python 2, 176 bytes - 3 = 173
```
def g(m,n):
 y,x,z,l,f='y','x','z','l','%'+str(len(str(max(m*m,n*n))))+'s'
 d={y:m*n,x:n*n,z:m*m,l:'\n'}
 for i in map(lambda x:d[x],(y*m+x*n+l)*n+(z*m+y*n+l)*m): print f % i,
```
This uses Python string functions to create a character grid, then replaces the characters with integers and prints formatted output. 
[Answer]
# Matlab, 58 − 3 = 55
Using an anonymous function:
```
@(a,b)flipud(blkdiag(a^2*ones(a)-a*b,b^2*ones(b)-a*b)+a*b)
```
Example:
```
>> @(a,b)flipud(blkdiag(a^2*ones(a)-a*b,b^2*ones(b)-a*b)+a*b)
ans = 
    @(a,b)flipud(blkdiag(a^2*ones(a)-a*b,b^2*ones(b)-a*b)+a*b)
>> ans(4,3)
ans =
    12    12    12    12     9     9     9
    12    12    12    12     9     9     9
    12    12    12    12     9     9     9
    16    16    16    16    12    12    12
    16    16    16    16    12    12    12
    16    16    16    16    12    12    12
    16    16    16    16    12    12    12
>> @(a,b)flipud(blkdiag(a^2*ones(a)-a*b,b^2*ones(b)-a*b)+a*b)
ans = 
    @(a,b)flipud(blkdiag(a^2*ones(a)-a*b,b^2*ones(b)-a*b)+a*b)
>> ans(0,3)
ans =
     9     9     9
     9     9     9
     9     9     9
```
### (Old solution) 59 − 3 = 56
Using an anonymous function:
```
@(a,b)[b*a*ones(b,a) b^2*ones(b);a^2*ones(a) a*b*ones(a,b)]
```
[Answer]
# C, (125 - 3) bytes
```
i,j,a;main(b,s){for(sscanf(gets(s),"%d %d",&a,&b);j<a+b;)printf(++i>a+b?i=!++j,"\n":"%*d",strlen(s)*2,(i<a?a:b)*(j<b?b:a));}
```
Input is taken as two space-separated integers on the same line. Each cell is padded with spaces to twice length of the input string. 
[Answer]
# Pyth, 39 − 3 = 36
Pyth doesn't have built-in matrix formatting, which greatly increases the size, as one has to manually pad the output numbers. Here's what I came up with.
```
JAQL*b]jdm.[`d\ l`eS^R2Jsm*d]*bdJj+yHyG
```
[Try it online.](https://pyth.herokuapp.com/?code=JAQL*b%5Djdm.%5B%60d%5C%20l%60eS%5ER2Jsm*d%5D*bdJj%2ByHyG&input=4%2C3&debug=0)
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), \$6 - 3 = 3\$ bytes
```
x`×þU$
```
[Try it online!](https://tio.run/##y0rNyan8/78i4fD0w/tCVf4fbnfXzHrUuO/QtkPb/v@PNtFRMI7VUYg2hNIGIBoA "Jelly – Try It Online")
A port of the APL and J answers. Takes input as `[a, b]`
## How it works
```
x`×þU$ - Main link. Takes a pair `[a, b]` on the left
 `     - Using [a, b] as both arguments:
x      -   Repeat a a times and b b times
     $ - To this repeated array:
    U  -   Reverse the array
  ×þ   -   Generate a multiplication table
```
[Answer]
# [Blocks](https://esolangs.org/wiki/Unnamed), ~~52~~ ~~62~~ ~~82~~ ~~87~~ 51 bytes
```
::`+`1|U;{`*`1}|A;`+`1,0+`1={`1^2}|;0+`,`1+`={`^2}|
```
Ungolfed:
```
::
  ` + `1                    | Expand;
  {` * `1}                  | SetAll;
  ` + `1, 0 + `1 = {`1 ^ 2} | Set;
  0 + `, `1 + `  = {` ^ 2}  | Set
```
[Try it](http://vihanserver.tk/p/Unnamed/?code=%3F%3AF%3A%60%2B%601%7CU%3B%60%2B%601%2C0%2B%601%7C%24a%3B%24a%3D%7B%601%5E2%7D%7C%3B%24a%3D%7B%60*%601%7D%7Cn%3B0%2B%60%2C%601%2B%60%3D%7B%60%5E2%7D%7C)
]