text:
How many Magic Cubes?
Your Task:
You all know what a magic square is!  But what about a magic cube?  A magic cube is the 3D version of a magic square, and is a set of numbers in a cube, where the sums of every straight (not diagonal) line are equal.  You must write a program or function that receives an integer, and returns the number of valid magic cubes made up of up to one of each integer between 1 and that integer (inclusive).
Input:
An integer.
Output:
The number of magic cubes you can make by using up to one of of each integer between 1 and the input.  A cube with various rotations should only be counted once.
Scoring:
This is code-golf, lowest byte count wins.
BOUNTY:
I will award a 100 rep bounty to the first user that manages to do this in < 100 bytes without using built-ins designed specifically towards magic cubes or squares (looking at you Mathematica).

So if a bunch of users all get <100 bytes you'll give +100 to all of them?

"Between integer 1 and the input." Inclusive or exclusive?

Also, you might want to specify how exactly a magic cube works.

A magic cube "is a set of numbers in a cube, where the sums of every straight (not diagonal) line are equal."

Test cases would be good.

Sorry @HyperNeutrino, fixed now.

Yes, I will add some as soon as I finish writing my (very ungolfed) code that is technically an answer.  Until then, I don't want to calculate one for any number > 27 (1-27 are all the number inputted)

It would quite literally take days to be reasonably sure you haven't missed one.  It took me nearly an hour to find the one I provided as an example.

for n=27 there are at least 4.I say at least because rows, columns, pillars, AND space diagonals sum to  42 but NOT cross section diagonals.  http://mathworld.wolfram.com/SemiperfectMagicCube.html

The given magic cube is definitely not valid, since 9+31+60=100≠106=34+43+29.

You should add some test cases

Thanks @Pietu1998.  Great, it took me quite a while just to find one I thought worked!

Thanks, @Jenny_mathy.  Sweet, despite the magic cube I though I found being wrong, turns out that there are magic cubes.

I will @LuisMendo, as soon as I manage to make sure I have a test case that I haven't missed any magic cubes for.

“A cube with various rotations should only be counted once.” What about reflections? Or permutation of layers?

Reflections and permutations are counted multiple times, as they are technically different cubes.

Clingo, 220 + 2 = 222 bytes
1{s(S):S=0..n,S**3==n}.
A{a(0..n-1,A)}:-A=1..n.
:-a(P,A-1),{a(P,A)}0,A<n.
:-s(S),{a(P,A):P-P/K\S*K=Q-Q/K\S*K}>(S*n+S)/2,Q=0..n,K=(1;S;S*S).
:-s(S),a(((0;1)+(0;S)+(0;S*S))*~-S,A),{a(0,A)}0.
:-s(S),a((S;S*S)*~-S,A),{a(S-1,A)}0.

Run with clingo magic-cubes.lp -n0 -cn=INPUT.  The answer will be printed next to Models.
All newlines are optional and shown here for clarity but excluded from the byte count.  I’m scoring +2 bytes for -n0 (“count all models”).
The last two lines ensure that only one rotated version of each cube is counted.
The answers for 1, 8, 27 are quickly found to be 1, 0, 216; the rest are probably too hard.
If you want to see the cubes in a more readable format, add b((P\S,P/S\S,P/S/S),A):s(S),-a(P,A),not a(P,A-1). #show b/2.
$ clingo magic-cubes.lp -n0 -cn=1
clingo version 5.1.0
Reading from magic-cubes.lp
Solving...
Answer: 1
a(0,1) s(1)
SATISFIABLE

Models       : 1
Calls        : 1
Time         : 0.009s (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s)
CPU Time     : 0.010s
$ clingo magic-cubes.lp -n0 -cn=8
clingo version 5.1.0
Reading from magic-cubes.lp
Solving...
UNSATISFIABLE

Models       : 0
Calls        : 1
Time         : 0.010s (Solving: 0.00s 1st Model: 0.00s Unsat: 0.00s)
CPU Time     : 0.000s
$ clingo magic-cubes.lp -n0 -cn=27
clingo version 5.1.0
Reading from magic-cubes.lp
Solving...
Answer: 1
a(7,1) a(7,2) a(13,2) a(7,3) a(13,3) a(19,3) a(7,4) a(13,4) a(15,4) a(19,4) a(7,5) a(13,5) a(15,5) a(19,5) a(21,5) a(0,6) a(7,6) a(13,6) a(15,6) a(19,6) a(21,6) a(0,7) a(7,7) a(13,7) a(15,7) a(19,7) a(21,7) a(26,7) a(0,8) a(5,8) a(7,8) a(13,8) a(15,8) a(19,8) a(21,8) a(26,8) a(0,9) a(5,9) a(7,9) a(11,9) a(13,9) a(15,9) a(19,9) a(21,9) a(26,9) a(0,10) a(2,10) a(5,10) a(7,10) a(11,10) a(13,10) a(15,10) a(19,10) a(21,10) a(26,10) a(0,11) a(2,11) a(5,11) a(7,11) a(11,11) a(13,11) a(15,11) a(17,11) a(19,11) a(21,11) a(26,11) a(0,12) a(2,12) a(5,12) a(7,12) a(11,12) a(13,12) a(15,12) a(17,12) a(19,12) a(21,12) a(23,12) a(26,12) a(0,13) a(2,13) a(5,13) a(7,13) a(10,13) a(11,13) a(13,13) a(15,13) a(17,13) a(19,13) a(21,13) a(23,13) a(26,13) a(0,14) a(2,14) a(5,14) a(7,14) a(10,14) a(11,14) a(13,14) a(15,14) a(17,14) a(19,14) a(21,14) a(23,14) a(25,14) a(26,14) a(0,15) a(2,15) a(4,15) a(5,15) a(7,15) a(10,15) a(11,15) a(13,15) a(15,15) a(17,15) a(19,15) a(21,15) a(23,15) a(25,15) a(26,15) a(0,16) a(2,16) a(4,16) a(5,16) a(7,16) a(10,16) a(11,16) a(13,16) a(15,16) a(17,16) a(18,16) a(19,16) a(21,16) a(23,16) a(25,16) a(26,16) a(0,17) a(2,17) a(4,17) a(5,17) a(6,17) a(7,17) a(10,17) a(11,17) a(13,17) a(15,17) a(17,17) a(18,17) a(19,17) a(21,17) a(23,17) a(25,17) a(26,17) a(0,18) a(2,18) a(4,18) a(5,18) a(6,18) a(7,18) a(10,18) a(11,18) a(12,18) a(13,18) a(15,18) a(17,18) a(18,18) a(19,18) a(21,18) a(23,18) a(25,18) a(26,18) a(0,19) a(2,19) a(3,19) a(4,19) a(5,19) a(6,19) a(7,19) a(10,19) a(11,19) a(12,19) a(13,19) a(15,19) a(17,19) a(18,19) a(19,19) a(21,19) a(23,19) a(25,19) a(26,19) a(0,20) a(2,20) a(3,20) a(4,20) a(5,20) a(6,20) a(7,20) a(9,20) a(10,20) a(11,20) a(12,20) a(13,20) a(15,20) a(17,20) a(18,20) a(19,20) a(21,20) a(23,20) a(25,20) a(26,20) a(0,21) a(2,21) a(3,21) a(4,21) a(5,21) a(6,21) a(7,21) a(9,21) a(10,21) a(11,21) a(12,21) a(13,21) a(15,21) a(17,21) a(18,21) a(19,21) a(21,21) a(23,21) a(24,21) a(25,21) a(26,21) a(0,22) a(2,22) a(3,22) a(4,22) a(5,22) a(6,22) a(7,22) a(9,22) a(10,22) a(11,22) a(12,22) a(13,22) a(14,22) a(15,22) a(17,22) a(18,22) a(19,22) a(21,22) a(23,22) a(24,22) a(25,22) a(26,22) a(0,23) a(2,23) a(3,23) a(4,23) a(5,23) a(6,23) a(7,23) a(9,23) a(10,23) a(11,23) a(12,23) a(13,23) a(14,23) a(15,23) a(17,23) a(18,23) a(19,23) a(20,23) a(21,23) a(23,23) a(24,23) a(25,23) a(26,23) a(0,24) a(2,24) a(3,24) a(4,24) a(5,24) a(6,24) a(7,24) a(8,24) a(9,24) a(10,24) a(11,24) a(12,24) a(13,24) a(14,24) a(15,24) a(17,24) a(18,24) a(19,24) a(20,24) a(21,24) a(23,24) a(24,24) a(25,24) a(26,24) a(0,25) a(2,25) a(3,25) a(4,25) a(5,25) a(6,25) a(7,25) a(8,25) a(9,25) a(10,25) a(11,25) a(12,25) a(13,25) a(14,25) a(15,25) a(17,25) a(18,25) a(19,25) a(20,25) a(21,25) a(22,25) a(23,25) a(24,25) a(25,25) a(26,25) a(0,26) a(1,26) a(2,26) a(3,26) a(4,26) a(5,26) a(6,26) a(7,26) a(8,26) a(9,26) a(10,26) a(11,26) a(12,26) a(13,26) a(14,26) a(15,26) a(17,26) a(18,26) a(19,26) a(20,26) a(21,26) a(22,26) a(23,26) a(24,26) a(25,26) a(26,26) a(0,27) a(1,27) a(2,27) s(3) a(3,27) a(4,27) a(5,27) a(6,27) a(7,27) a(8,27) a(9,27) a(10,27) a(11,27) a(12,27) a(13,27) a(14,27) a(15,27) a(16,27) a(17,27) a(18,27) a(19,27) a(20,27) a(21,27) a(22,27) a(23,27) a(24,27) a(25,27) a(26,27)
Answer: 2
[…]
Answer: 216
a(0,2) a(12,1) a(12,2) a(0,3) a(12,3) a(24,3) a(0,4) a(12,4) a(22,4) a(24,4) a(0,5) a(10,5) a(12,5) a(22,5) a(24,5) a(0,6) a(7,6) a(10,6) a(12,6) a(22,6) a(24,6) a(0,7) a(5,7) a(7,7) a(10,7) a(12,7) a(22,7) a(24,7) a(0,8) a(5,8) a(7,8) a(10,8) a(12,8) a(20,8) a(22,8) a(24,8) a(0,9) a(5,9) a(7,9) a(10,9) a(12,9) a(17,9) a(20,9) a(22,9) a(24,9) a(0,10) a(5,10) a(7,10) a(10,10) a(12,10) a(16,10) a(17,10) a(20,10) a(22,10) a(24,10) a(0,11) a(4,11) a(5,11) a(7,11) a(10,11) a(12,11) a(16,11) a(17,11) a(20,11) a(22,11) a(24,11) a(0,12) a(4,12) a(5,12) a(7,12) a(10,12) a(12,12) a(16,12) a(17,12) a(19,12) a(20,12) a(22,12) a(24,12) a(0,13) a(4,13) a(5,13) a(7,13) a(10,13) a(12,13) a(16,13) a(17,13) a(19,13) a(20,13) a(22,13) a(24,13) a(26,13) a(0,14) a(4,14) a(5,14) a(7,14) a(10,14) a(12,14) a(14,14) a(16,14) a(17,14) a(19,14) a(20,14) a(22,14) a(24,14) a(26,14) a(0,15) a(2,15) a(4,15) a(5,15) a(7,15) a(10,15) a(12,15) a(14,15) a(16,15) a(17,15) a(19,15) a(20,15) a(22,15) a(24,15) a(26,15) a(0,16) a(2,16) a(4,16) a(5,16) a(6,16) a(7,16) a(10,16) a(12,16) a(14,16) a(16,16) a(17,16) a(19,16) a(20,16) a(22,16) a(24,16) a(26,16) a(0,17) a(2,17) a(4,17) a(5,17) a(6,17) a(7,17) a(10,17) a(12,17) a(14,17) a(16,17) a(17,17) a(19,17) a(20,17) a(21,17) a(22,17) a(24,17) a(26,17) a(0,18) a(2,18) a(4,18) a(5,18) a(6,18) a(7,18) a(9,18) a(10,18) a(12,18) a(14,18) a(16,18) a(17,18) a(19,18) a(20,18) a(21,18) a(22,18) a(24,18) a(26,18) a(0,19) a(2,19) a(4,19) a(5,19) a(6,19) a(7,19) a(9,19) a(10,19) a(11,19) a(12,19) a(14,19) a(16,19) a(17,19) a(19,19) a(20,19) a(21,19) a(22,19) a(24,19) a(26,19) a(0,20) a(2,20) a(4,20) a(5,20) a(6,20) a(7,20) a(8,20) a(9,20) a(10,20) a(11,20) a(12,20) a(14,20) a(16,20) a(17,20) a(19,20) a(20,20) a(21,20) a(22,20) a(24,20) a(26,20) a(0,21) a(2,21) a(4,21) a(5,21) a(6,21) a(7,21) a(8,21) a(9,21) a(10,21) a(11,21) a(12,21) a(14,21) a(16,21) a(17,21) a(19,21) a(20,21) a(21,21) a(22,21) a(23,21) a(24,21) a(26,21) a(0,22) a(2,22) a(4,22) a(5,22) a(6,22) a(7,22) a(8,22) a(9,22) a(10,22) a(11,22) a(12,22) a(14,22) a(16,22) a(17,22) a(18,22) a(19,22) a(20,22) a(21,22) a(22,22) a(23,22) a(24,22) a(26,22) a(0,23) a(2,23) a(4,23) a(5,23) a(6,23) a(7,23) a(8,23) a(9,23) a(10,23) a(11,23) a(12,23) a(14,23) a(15,23) a(16,23) a(17,23) a(18,23) a(19,23) a(20,23) a(21,23) a(22,23) a(23,23) a(24,23) a(26,23) a(0,24) a(2,24) a(3,24) a(4,24) a(5,24) a(6,24) a(7,24) a(8,24) a(9,24) a(10,24) a(11,24) a(12,24) a(14,24) a(15,24) a(16,24) a(17,24) a(18,24) a(19,24) a(20,24) a(21,24) a(22,24) a(23,24) a(24,24) a(26,24) a(0,25) a(1,25) a(2,25) a(3,25) a(4,25) a(5,25) a(6,25) a(7,25) a(8,25) a(9,25) a(10,25) a(11,25) a(12,25) a(14,25) a(15,25) a(16,25) a(17,25) a(18,25) a(19,25) a(20,25) a(21,25) a(22,25) a(23,25) a(24,25) a(26,25) a(0,26) a(1,26) a(2,26) a(3,26) a(4,26) a(5,26) a(6,26) a(7,26) a(8,26) a(9,26) a(10,26) a(11,26) a(12,26) a(14,26) a(15,26) a(16,26) a(17,26) a(18,26) a(19,26) a(20,26) a(21,26) a(22,26) a(23,26) a(24,26) a(25,26) a(26,26) a(0,27) a(1,27) a(2,27) s(3) a(3,27) a(4,27) a(5,27) a(6,27) a(7,27) a(8,27) a(9,27) a(10,27) a(11,27) a(12,27) a(13,27) a(14,27) a(15,27) a(16,27) a(17,27) a(18,27) a(19,27) a(20,27) a(21,27) a(22,27) a(23,27) a(24,27) a(25,27) a(26,27)
SATISFIABLE

Models       : 216
Calls        : 1
Time         : 6.101s (Solving: 6.07s 1st Model: 1.03s Unsat: 0.37s)
CPU Time     : 6.090s

I don't think that's what the question is asking for

This appears to calculate the number of valid magic cubes with side length n, whereas the question is asking for the number for valid magic cubes in which every number is unique and less than or equal to n.

Yes, this is incorrect.

@ASCII-only Fixed.

Ruby, 275 bytes
n=gets.to_i;p (2.upto(n**(1/3r)).map{|i|(1..n).to_a.permutation(i**3).map{|x|c=eval'x'+".each_slice(#{i}).to_a"*2;[c,c.map(&:transpose),c.transpose.map(&:transpose)].map{|q|q.map{|a|a.map{|b|b.inject(:+)}}.flatten.uniq.length}.inject(:+)==3?1:0}}+[0]).flatten.inject(:+)/48+n

Try it online!
In theory, this works. In practice, since it creates every permutation of the list of possible numbers, it'll take hopelessly large amounts of time and memory for any input more than 13 or so. I haven't taken the time to test it past 12, but it seems no 2×2×2 magic cubes exist for that range, so all it really does is tell you how many 1×1×1 cubes you can make.
I "golfed" it a bit (really just made it hard to read for minimal size reduction returns). I'm sure the size can be reduced quite a bit, though getting it under 100 characters is a pretty tall order.
Ruby 2.4 added .sum, but TIO doesn't support it yet, so this has a few .inject(:+)s.
I'll add a non-golfed version + explanation if requested.

There are no 2×2×2 magic cubes with any range. The top face would have to be a 2×2 magic square, but there aren't any of those either: a1+a2 = a1+b1, so a2=b1, which violates the rule that all the values must be distinct.

@ais523 You're right; I hadn't thought of that. In that case, I'm going to abandon this solution seeing as it's not a viable way of finding 3-cubes.

Jelly, 36 bytes
;Z;Z€ẎS€E
*3³œcŒ!€Ẏs€s€¹Ç€S
Ç€ḊS÷24+

Try it online!
As you expect, it's terribly slow.
Explanation

Link 1: Given a cube, check if it's valid.

;Z;Z€ẎS€E   Input: N =
            [  [ [a,b],    [ [e,f],
                 [c,d] ],    [g,h] ]   ]

;Z          Concatenate with zip of N. The zip (transpose) of N is
            [   [ [a,b],    [ [c,d],
                  [e,f] ],    [g,h] ]   ]
            (by treating each 2-element block as an unit
            and transpose the large table)

;Z€         Concatenate with plane-wise zip of N, that is
            [  [ [a,c],    [ [e,g],
                 [b,d] ],    [f,h] ]   ]
            (transpose each 2x2 block)

            The current value is:
            [ [ [a,b],   [ [e,f],   [ [a,b],   [ [c,d],   [ [a,c],   [ [e,g],
                 [c,d] ],   [g,h] ],   [e,f] ],   [g,h] ],   [b,d] ],   [f,h] ] ]

Ẏ           Tighten, concatenate all elements inside, similar to `;/`.
            Get [ [a,b], [c,d], [e,f], [g,h],
                  [a,b], [e,f], [c,d], [g,h],
                  [a,c], [b,d], [e,g], [f,h] ]
S€          Sum each sublist. `ZS` also works.
E           All Equal? `1` if all elements are equal, `0` otherwise.

Link 2: Given a side length x, generate all cubes with that side length and calculate number of valid cubes.

*3³œcŒ!€Ẏs€s€¹Ç€S   Given: `x` (side length).
*3                  Calculate x³.
  ³                 First commandline argument. (n)
   œc               Generate all subsets of the range `[1..n]` having length x³.
     Œ!€Ẏ           All permutation of each and tighten.
                      (the current value is a list of all ways to choose
                      an ordered tuple of x³ elements from `[1..n]`)
         s€s€       Split each twice into slices of length `x`.
                      On a list of (list of x³ integers), this format
                      each sublist into a cube.
             ¹      Do nothing. Because Jelly is a tacit programming language
                      without this the program will behave differently.
              Ç€    Apply last link for €ach.
                S   Sum.

Link 3 (main link): For all side lengths from 1 to n, calculate number of cubes (rotations are counted multiple times) for each side length, dequeue and sum it (so we get the sum of number of cubes with side length >= 2), divide by 24 (to avoid duplication of cubes) and add the number of side length 1 cube (input).

Ç          Apply last link...
 €           for €ach element from `1` to `n`.
  Ḋ        Ḋequeue, dispose the result for value 1.
   S÷24    Sum and divide by 24.
       +   Add the input (number of cubes with side length 1)

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


text:
Am I a Secondary Taxicab?
Background
Ramanujan's number, \$1729\$, is called a taxi-cab number due to the (possibly apocryphal) tale of Hardy boarding a cab to visit Ramanujan in hospital having this number, which seemed bland to him.
It's since known as the most famous of a class of integers known as "taxicab numbers" which are expressible as the sum of two \$n\$th powers (of positive integers) in two (or sometimes \$k\$) different ways.
\$1729\$ is the smallest natural number expressible as the sum of 2 cubes in 2 different ways, making it the first \$3,2\$ taxicab number (\$n,k\$ being general).
Challenge
Given a number, decide whether it is a \$3,2\$ 'secondary taxicab number' - meaning it fulfils the same constraint as \$1729\$ (2 unique sums of cubes), but does not have to be the smallest such integer of the \$3,2\$ class (that being 1729, of course).
Example cases
$$1729 = 10^3 + 9^3 = 12^3 + 1^3 \\
4104 = 15^3 + 9^3 = 16^3 + 2^3 \\
13832 = 2^3 + 24^3 = 18^3 + 20^3$$
As well as \$20683, 32832, 39312...\$
Scoring
This is code-golf, so the shortest answer in each language wins.

Rough Matlab code to find other cases by brute force:
for k = 1729:20000
    C = sum(round(mod(real((k-[1:ceil(k^(1/3))].^3).^(1/3)),1)*10000)/10000==1);
    if C > 1
        D = (mod(C,2)==0)*C/2 + (mod(C,2)==1)*((C+1)/2);
        disp([num2str(k),' has ',num2str(D),' solns'])
    end
end

Welcome to PPCG! I edited your question a bit to make it a bit more clear. Would you be willing to add some test cases?

Yep, I was struggling because I'm at work and don't have Matlab, but managed to get Octave online to work and found 4104=16^3+4^3=15^3+9^3

1729 sould be true or false?

True. All non-taxicabs false.

If 1729 is true, then can you explain (or alter/remove) but is not the smallest such integer of the "3,2" class (that being 1729, of course)? Thanks!

Good point, sorry about that!

As far as I can tell, the two answers interpreted the spec differently. Should 87539319 = 167³ + 436³ = 228³ + 423³ = 255³ + 414³ return true or false?

Yes, that should be a true, I could have clarified "3,2" as a sum of two cubes in "at least** two ways".

A001235

"Both men were mathematicians and liked to think about numbers." - This was the point I got to before I had to check whether I was on Simple English Wikipedia. Anyone else?

Do there need to be exactly two ways to write the number, or at least two?

someone should write an answer in Taxi https://bigzaphod.github.io/Taxi/

05AB1E, 9 bytes
Code (very slow)
L3mãOQO3›

Code (much faster), 12 bytes
tL3mDδ+˜QO3›

Uses the 05AB1E encoding. Try it online!
Explanation
t                # Square root (not necessary but added for speed)
 L               # Create a list [1 .. sqrt(input)]
  3m             # Raise to the power of 3
    D            # Duplicate
     δ+          # 2 dimensional addition
       ˜         # Deep-flatten the entire list
        Q        # Check which are equal to the input
         O       # Sum up to get the number of equalities
          3›     # Checks whether there are 4 or more equalities. In order for a number
                   to be a secondary taxicab number, there are at least two distinct
                   ways to get to that number and 4 ways when you also take reversed
                   arguments in account.

Surely you could save a byte by removing the square root. This is code-golf, not fastest-code.

@Christian I have added a slow version of the code.

Jelly, 9 bytes
Credits to Erik the Outgolfer.
Œċ*3S€ċ>1

Try it online!
This is too slow that it won't even work for 1729 online.
Much faster, 12 bytes
Credits to Dennis.
R*3fRŒċS€ċ>1

Try it online!

I just tested this with "4104" and it passed. :)
Haven't found any beyond this yet, but that was lightning fast!

Ðf⁸ can become fR. The second ⁸ can be removed.

The second ⁸ can be removed indeed, but the fR swap leads to failure.

By the way, this is [tag:code-golf] so we don't care about speed ;) but you can still include the fast version in the TIO link.

You don't need to care about speed, just do Œċ*3S€ċ>1.

@DrQuarius Could you give me an example where fR fails? This keeps all cubes that are not greater than the input, which can't possibly be part of a valid sum.

@Dennis♦ I just find it fails even on 1729 when I replace  Ðf⁸ with fR... https://tio.run/##y0rNyan8/z9Iy9gmLejopCPdwY@a1hzpftS4w87w////huZGlgA

PS @Leaky Nun, if you amend your answer to 11 bytes, I'll accept yours as the winner, since my MATL solution is 12 at best (as is the 05AB1E solution).

@DrQuarius done

@Dennis it's <Ðf⁸ that can become fR, not just Ðf⁸.

@LeakyNun Right, my bad.

Mathematica, 35 bytes
Count[#^3+#2^3&~Array~{#,#},#,2]>2&

Pure function taking a positive integer and returning True or False.
#^3+#2^3&~Array~{#,#} tabulates all sums of cubes of two integers between 1 and the input. (This would be much faster with a sensible bound on the integers to be cubed, like the cube root of the input; but that would take precious bytes. As it is, the code takes about 30 seconds on the input 13832 and scales at least quadratically in the input.) Count[...,#,2] counts how many times the input appears in this list at nest-level 2; if this number is greater than 2, then the input is a semi-taxicab number (greater than 2, rather than greater than 1, since a^3+b^3 and b^3+a^3 are being counted separately).

Mathematica, 38 37 bytes
Tr[1^PowersRepresentations[#,2,3]]>1&

-1 byte thanks to @GregMartin
As always, there is a Mathematica builtin to everything.

Assuming that the OP is ok with more-than-2-representations, then I believe Tr[1^...] works in place of Length@.

APL (dzaima/APL), 15 bytes
{4≤⍵⍧∘.+⍨3*⍨⍳⍵}

Try it online!
Same method as all the other answers. Only works till 4104 due to brute forcing.
more than 20 bytes golfed off with dzaima's help at the APL orchard.
The output appears with a ⊂ next to it, which has been patched in the latest version of the interpreter.
Explanation
{4≤⍵⍧∘.+⍨3*⍨⍳⍵} ⍵ → input
         3*⍨⍳⍵  range 1 to n, cubed
     ∘.+⍨       dot product, addition with itself
   ⍵⍧           number of times ⍵ appears in the sums
 4≤             is 4 less than or equal to that?

Mathematica, 48 bytes
Length@Solve[x^3+y^3-#==0<x<y,{x,y},Integers]>1&

input

[4104]

output

True

Note that #!=1729&& is no longer necessary now that the spec has been clarified.

Could you use Solve rather than Reduce?

of course...1 byte is 1 byte!

Can save one more byte with Length@Solve[x^3+y^3-#==0<x<y,{x,y},Integers]>1& which replaces the && with - and a little bit of rearranging.

JavaScript (ES7), 63 bytes
A relatively fast recursive function which eventually returns a boolean.
f=(n,k,r=0,x=n-k**3)=>x<0?r>3:f(n,-~k,r+=(x**(1/3)+.5|0)**3==x)

Demo

f=(n,k,r=0,x=n-k**3)=>x<0?r>3:f(n,-~k,r+=(x**(1/3)+.5|0)**3==x)

console.log([...Array(40000).keys()].filter(n => f(n)))

MATL (16 15 bytes) (13 12 ideally)
.4^:3^2XN!sG=sq

Try it online!
Explanation:
Based on the Jelly solution of 'Leaky Nun', just converted to MATL, probably redundant in some parts and can be improved:
.4^  % rough cube root of input, as maximum potential integer N.
:3^   % create array of all cubes from 1^3 up to N^3.
2XN   % do nchoosek on cube array, creating all possible pairs (k=2) to add.
!s    % transpose array and add all pairs to find sums.
G=    % find all pairs that equal the original input.
sq   % if there is more than one solution, then pass the test.

Note: falsy outputs include 0 and -1, while truthy output is 1. Thanks to Luis Mendo for saving an extra byte here replacing "s1>" with "sq".
Ideally (13 12 bytes):
:3^2XN!sG=sq

...is enough, but for larger numbers this crashes on tio.run's page.

Original:
MATL (19 bytes)
XH.34^:3^2XN!sH=s1>

If any truthy output is valid, you can replace 1> by q. Also, you have H instead of G in the explanation. The fact that the program crashes for large numbers is usually irrelevant for scoring. If it works given enough time and memory that's acceptable, unless the challenge specifies otherwise

Thanks Luis! I'm new to "truthy" outputs, but this works nicely now. Edited to amend. Also, thanks for creating such a fun and easy to use esolang!

Python, 71 bytes
Try it online
lambda x:len([i for i in range(x)for j in range(i,x)if i**3+j**3==x])>1

Ruby, 52 bytes
->n{r=*1..n;r.product(r).count{|i,j|i**3+j**3==n}>1}

Try it online!
Since this version creates a massive n2 sized array, it fails on all true testcases higher than 1729, here is a modified version that has a smaller array size of about n2/3, which successfully checks at least up to 31392.
Try it online! (modified)

PHP, 76 bytes
for(;$i++<$argn**(1/3);)for($n=1;$n<$i;)$n++**3+$i**3!=$argn?:$c++;echo$c>1;

Try it online!
Search till 400000 Try it online!

Perl 5 -pa, 49 bytes
$_=1<grep{//;grep$'**3+$_**3=="@F",$_.."@F"}1..$_

Try it online!

Add++, 32 bytes
D,g,@,3^AR3€Ω^$€+
L,R€gb+A€=b+2=

Try it online!
The Footer in the TIO link is simply a faster version (b+ \$\to\$ BFB])
How it works
D,g,@,		; Define a helper function, g
		; It takes an int;	STACK = [5]
	3^	; Cube;			STACK = [125]
	AR	; Argument range;	STACK = [125 [1 2 3 4 5]]
	3€Ω^	; Cube each;		STACK = [125 [1 8 27 64 125]]
	$€+	; Add the cube to each;	STACK = [[126 133 152 189 250]]

L,		; Define the main function
		; Takes an int;		STACK = [1729]
	R	; Range;		STACK = [[1 2 3 ... 1728 1729]]
	€g	; Run g over each;	STACK = [[[2] [9 16] ... ]]
	b+	; Concatenate;		STACK = [[2 9 16 ...]]
	A€=b+	; Count argument;	STACK = [2]
	2=	; Equals 2?		STACK = [1]

source: Stack Exchange

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

sort: votes


text:
Draw ASCII boxes in boxes
Problem
given input a,b,c
where a,b,c are positive even integers
and a > b > c
Make a box of any allowed character  with dimensions a x a
Center a box of a different allowed character with dimensions b x b within the previous
Center a box of another different allowed character with dimensions c x c within the previous
Allowed Characters are ASCII characters are in [a-zA-z0-9!@#$%^&*()+,./<>?:";=_-+]
Input a=6, b=4, c=2
######
#****#
#*@@*#
#*@@*#
#****#
######

Input a=8, b=6, c=2
########
#******#
#******#
#**@@**#
#**@@**#
#******#
#******#
########

Input a=12, b=6, c=2
############
############
############
###******###
###******###
###**@@**###
###**@@**###
###******###
###******###
############
############
############

Rules

Shortest code wins
Remember that you can choose which char to print within the range given
Trailing newlines accepted
Trailing whitespace accepted
functions may return string with newlines, string array, or print it

Will the input always be valid (i.e. each number is at least 2 less than the previous)? And will the numbers always be (all even) or (all odd) to ensure symmetrical drawing?

Quite similar to Show tree rings age.

@Christian the first 3 lines define those requirements, please let me know if they are sufficient.

@StefanDelport Right you are, I missed that. Thanks.

Charcoal, 14 bytes
Ｆ#*@ＵＯ÷Ｎ²ι‖Ｃ←↑

Try it online! Link is to verbose version of code.

Verbose mode should work now

Jelly,  20  19 bytes
-1 byte using the quick ` to avoid a link, as suggested by Erik the Outgolfer.
H»þ`€Ḣ>Ð€HSUṚm€0m0Y

A full program taking a list [a,b,c] printing the boxes using a:2 b:1 c:0
... in fact, as is, it will work for up to 10 boxes, where the innermost box is 0 (for example).
Try it online!
How?
H»þ`€Ḣ>Ð€HSUṚm€0m0Y - Main link: list of boxes, B = [a, b, c]
H                   - halve B = [a/2, b/2, c/2]
    €               - for €ach:
   `                -   repeat left argument as the right argument of the dyadic operation:
  þ                 -     outer product with the dyadic operation:
 »                  -       maximum
                    - ... Note: implicit range building causes this to yield
                    -       [[max(1,1),max(1,2),...,max(1,n)],
                    -        [max(2,1),max(2,2),...,max(2,n)],
                    -        ...
                    -        [max(n,1),max(n,2),...,max(n,n)]]
                    -       for n in [a/2,b/2,c/2]
     Ḣ              - head (we only really want n=a/2 - an enumeration of a quadrant)
         H          - halve B = [a/2, b/2, c/2]
       Ð€           - map across right with dyadic operation:
      >             -   is greater than?
                    - ...this yields three copies of the lower-right quadrant
                    -    with 0 if the location is within each box and 1 if not
          S         - sum ...yielding one with 0 for the innermost box, 1 for the next, ...
           U        - upend (reverse each) ...making it the lower-left
            Ṛ       - reverse ...making it the upper-right
             m€0    - reflect €ach row (mod-index, m, with right argument 0 reflects)
                m0  - reflect the rows ...now we have the whole thing with integers
                  Y - join with newlines ...making a mixed list of integers and characters
                    - implicit print - the representation of a mixed list is "smashed"

Python 2, 107 103 bytes
a,b,c=input()
r=range(1-a,a,2)
for y in r:
 s=''
 for x in r:m=max(x,y,-x,-y);s+=`(m>c)+(m>b)`
 print s

Full program, prints boxes with a=2,b=1,c=0
Slightly worse answer, with list comprehension (104 bytes):
a,b,c=input()
r=range(1-a,a,2)
for y in r:print''.join(`(m>c)+(m>b)`for x in r for m in[max(x,y,-x,-y)])

C#, 274 232 bytes
using System.Linq;(a,b,c)=>{var r=new string[a].Select(l=>new string('#',a)).ToArray();for(int i=0,j,m=(a-b)/2,n=(a-c)/2;i<b;++i)for(j=0;j=n&i+m<n+c&j+m>n&j+m<=n+c?"@":"*");return r;}

Terrible even for C# so can definitely be golfed but my mind has gone blank.
Full/Formatted version:
using System;
using System.Linq;

class P
{
    static void Main()
    {
        Func<int, int, int, string[]> f = (a,b,c) =>
        {
            var r = new string[a].Select(l => new string('#', a)).ToArray();

            for (int i = 0, j, m = (a - b) / 2, n = (a - c) / 2; i < b; ++i)
                for (j = 0; j = n & i + m < n + c &
                        j + m > n & j + m <= n + c ? "@" : "*");

            return r;
        };

        Console.WriteLine(string.Join("\n", f(6,4,2)) + "\n");
        Console.WriteLine(string.Join("\n", f(8,6,2)) + "\n");
        Console.WriteLine(string.Join("\n", f(12,6,2)) + "\n");

        Console.ReadLine();
    }
}

You seem to have regained your mind, j + m <= n + c can become  n + c >  j + m

As well then as i + m >= n to n < i + m

you use i+m 4 times, so you can add it to a variable in your for to save some

Not checked these properly, but: you never use i in isolation, just initialise i=m and compare i<b+m; or... just use i, init i=0 but loop on ib=>c=>(d=("#"[r="repeat"](a)+`
`)[r](f=a/2-b/2))+(e=((g="#"[r](f))+"*"[r](b)+g+`
`)[r](h=b/2-c/2))+(g+(i="*"[r](h))+"@"[r](c)+i+g+`
`)[r](c)+e+d

Try it

fn=
a=>b=>c=>(d=("#"[r="repeat"](a)+`
`)[r](f=a/2-b/2))+(e=((g="#"[r](f))+"*"[r](b)+g+`
`)[r](h=b/2-c/2))+(g+(i="*"[r](h))+"@"[r](c)+i+g+`
`)[r](c)+e+d
oninput=_=>+x.value>+y.value&&+y.value>+z.value&&(o.innerText=fn(+x.value)(+y.value)(+z.value))
o.innerText=fn(x.value=12)(y.value=6)(z.value=2)
label,input{font-family:sans-serif;}
input{margin:0 5px 0 0;width:50px;}
a: <input id=x min=6 type=number step=2>b: <input id=y min=4 type=number step=2>c: <input id=z min=2 type=number step=2>

Explanation
a=>b=>c=>            :Anonymous function taking the 3 integers as input via parameters a, b & c
(d=...)              :Assign to variable d...
("#"[r="repeat"](a)  :  # repeated a times, with the repeat method aliased to variable r in the process.
+`\n`)               :  Append a literal newline.
[r](f=a/2-b/2)       :  Repeat the resulting string a/2-b/2 times, assigning the result of that calculation to variable f.
+                    :Append.
(e=...)              :Assign to variable e...
(g=...)              :  Assign to variable g...
"#"[r](f)            :    # repeated f times.
+"*"[r](b)           :  Append * repeated b times.
+g+`\n`)             :  Append g and a literal newline.
[r](h=b/2-c/2)       :  Repeat the resulting string b/2-c/2 times, assigning the result of that calculation to variable h.
+(...)               :Append ...
g+                   :  g
(i=...)              :  Assign to variable i...
"*"[r](h)            :    * repeated h times.
+"@"[r](c)           :  @ repeated c times
+i+g+`\n`)           :  Append i, g and a literal newline.
[r](c)               :...repeated c times.
+e+d                 :Append e and d.

Haskell, 126 bytes
f a b c=r[r["#*@"!!(v c+v b)|x<-[1..d a],let v k|x>a#k&&y>a#k=1|2>1=0]|y<-[1..d a]]where r x=x++reverse x;d=(`div`2);x#y=d$x-y

Try it online!

V, 70, 44, 42 bytes
Àé#@aÄÀG@b|{r*ÀG@c|{r@òjdòÍ.“.
ç./æ$pYHP

Try it online!
This is hideous. Eww. Much better. Still not the shortest, but at least somewhat golfy.
Saved two bytes thanks to @nmjmcman101!
Hexdump:
00000000: c0e9 2340 61c4 c047 4062 7c16 7b72 2ac0  ..#@a..G@b|.{r*.
00000010: 4740 637c 167b 7240 f26a 64f2 cd2e 932e  G@c|.{r@.jd.....
00000020: 0ae7 2e2f e624 7059 4850                 .../.$pYHP

You can combine your last two lines for two bytes saving Try it online!

@nmjcman101 Ah, good point. Thanks!

MATL, 26 23 22 20 18 bytes
2/t:<sPtPh!Vt!2$X>

Input is a column vector [a; b; c]. Output uses characters 2, 1, 0.
Try it online!
As an aside, it works for up to ten boxes, not just three. Here's an example with five boxes.

C (gcc), 97 bytes
x,y;f(a,b,c){for(y=1-a;y<a;y+=2,puts(""))for(x=1-a;x<a;x+=2)printf(x/c|y/c?x/b|y/b?"#":"*":"@");}

Try it online!

Mathematica, 49 bytes
Print@@@Fold[#~CenterArray~{#2,#2}+1&,{{}},{##}]&

Takes input [c, b, a]. The output is a=1, b=2, c=3.
How?
Print@@@Fold[#~CenterArray~{#2,#2}+1&,{{}},{##}]&
                                                &  (* Function *)
        Fold[                        ,{{}},{##}]   (* Begin with an empty 2D array.
                                                      iterate through the input: *)
                                    &              (* Function *)
             #~CenterArray~{#2,#2}                 (* Create a 0-filled array, size
                                                      (input)x(input), with the array
                                                      from the previous iteration
                                                      in the center *)
                                  +1               (* Add one *)
Print@@@                                           (* Print the result *)

@Jenny_mathy In the question: *functions may return string with newlines, string array, or print it." Grid does not make a String nor does it Print it.

Japt -h, 19 bytes
Takes input in reverse (c,b,a) and outputs an array of lines using = for the outer box, ! for the middle one and - for the inner one.
Æç-
4Æ=Õû¦gXz)NÅgXz

Try it
Æç-\n4Æ=Õû¦gXz)NÅgXz     :Implicit input of integers U=c, V=b & W=a
Æ                        :Map the range [0,U)
 ç-                      :  Repeat "-" U times
   \n                    :Reassign to U
     4Æ                  :Map each X in the range [0,4)
       =                 :  Reassign to U ...
        Õ                :  Transpose U
         û               :  Centre pad each element with (1) to length (2)
          ¦              :    "!=" (1)
           g             :    Get character at index (1)
            Xz           :    X floor divided by 2 (1)
               )         :    End index (1)
                N        :    Array of all inputs, i.e. [U,V,W] (2)
                 Å       :    Slice off the first element (2)
                  gXz    :    As above (2)
                         :Implicit output of last element of resulting array

Python 2, 87 bytes
a,_,_=t=input();r=~a
exec"r+=2;print sum(10**x/9*10**((a-x)/2)*(r*r<x*x)for x in t);"*a

Try it online!
Arithmetically computes the numbers to print by adding numbers of the form 111100. There's a lot of ugliness, probably room for improvement.

Java 10, 265 252 218 181 172 bytes
 (a,b,c)->{int r[][]=new int[a][a],t=a-b>>1,u=a-c>>1,x=b*b;for(;x-->0;r[x/b+t][x%b+t]=1)if(x<c*c)r[x/c+u][x%c+u]=8;var s="";for(var q:r){for(int Q:q)s+=Q;s+="\n";}return s;}

-34 bytes thanks to @ceilingcat.
Explanation:
Try it online.
(a,b,c)->{                  // Method with three integer parameters and String return-type
  int r[][]=new int[a][a],  //  Create a grid with dimensions `a` by `a`,
                            //  filled with 0s by default
      t=a-b>>1,             //  Calculate (a-b)/2
      u=a-c>>1,             //  Calculate (a-c)/2 as well
  x=b*b;for(;x-->0;         //  Loop `x` in the range (b*b, 0]:
    r[x/b+t][x%b+t]=1;      //   Fill the cells for the second square with 1s
    if(x<c*c)               //   And if `x` is smaller than c*c:
      r[x/c+u][x%c+u]=8;    //    Also start filling the center square cells with 8s
  var s="";                 //  Then create a return-String, starting empty
  for(var q:r){             //  Loop over the rows of the matrix:
    for(int Q:q)            //   Inner loop over the columns of the row:
      s+=Q;                 //    Append the current digit to the result-String
    s+="\n";}               //   Append a trailing new-line after every row
  return s;}                //  Return the result-String

JavaScript (ES6), 112
Anonymous function returning a multi line string. Characters 0,1,2
(a,b,c)=>eval("for(o='',i=-a;i<a;o+=`\n`,i+=2)for(j=-a;j=c|i<-c|j>=c|j<-c)+(i>=b|i<-b|j>=b|j<-b)")

Less golfed
(a,b,c)=>{
  for(o='',i=-a;i<a;o+=`\n`,i+=2)
    for(j=-a;j=c|i<-c|j>=c|j<-c)+(i>=b|i<-b|j>=b|j<-b)
  return o
}

var F=
(a,b,c)=>eval("for(o='',i=-a;i<a;o+=`\n`,i+=2)for(j=-a;j=c|i<-c|j>=c|j<-c)+(i>=b|i<-b|j>=b|j<-b)")

function update()
{
  var [a,b,c]=I.value.match(/\d+/g)
  O.textContent=F(a,b,c)
}

update()

a,b,c <input id=I value='10 6 2' oninput='update()'>

PHP >= 5.6, 121 bytes
for($r=A;$p?:$p=($z=$argv[++$i])**2;)$r[((--$p/$z|0)+$o=($w=$w?:$z)-$z>>1)*$w+$p%$z+$o]=_BCD[$i];echo chunk_split($r,$w);

Run with -nr or test it online.
Combined loops again ... I love them!
breakdown
for($r=A;                           # initialize $r (result) to string
    $p?:$p=($z=$argv[++$i])**2;)    # loop $z through arguments, loop $p from $z**2-1 to 0
    $r[((--$p/$z|0)+$o=
        ($w=$w?:$z)                     # set $w (total width) to first argument
        -$z>>1)*$w+$p%$z+$o]            # calculate position: (y+offset)*$w+x+offset
        =_BCD[$i];                      # paint allowed character (depending on $i)
echo chunk_split($r,$w);            # insert newline every $w characters and print

Mathematica, 173 bytes
(d=((a=#1)-(b=#2))/2;e=(b-(c=#3))/2;z=1+d;x=a-d;h=Table["*",a,a];h[[z;;x,z;;x]]=h[[z;;x,z;;x]]/.{"*"->"#"};h[[z+e;;x-e,z+e;;x-e]]=h[[z+e;;x-e,z+e;;x-e]]/.{"#"->"@"};Grid@h)&

input

[12,6,2]

PHP>=7.1, 180 bytes
In this case i hate that variables begin with a $ in PHP
for([,$x,$y,$z]=$argv;$i<$x*$x;$p=$r%$x)echo XYZ[($o<($l=$x-$a=($x-$y)/2)&$o>($k=$a-1)&$p>$k&$p<$l)+($o>($m=$k+$b=($y-$z)/2)&$o<($n=$l-$b)&$p>$m&$p<$n)],($o=++$i%$x)?"":"\n".!++$r;

PHP Sandbox Online

In this case, paint before print is a lot shorter. :D Or is it because I use $argv as an array? Have you tried that? Have You tried separate ternaries?

@Titus I don't know but my approch correct the input of invalid odd numbers

Canvas, 14 bytes
#*@Ｈ╶：＊ｌ⁸∔½：╋｝

Try it here!

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

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


text:
Is my prison secure?
Your challenge is given an input of a prison layout to work out whether any of the prisoners can escape.
Input
Input may be in any reasonable format such as a string, array, array of arrays etc. The input will consist of three characters, in this case #, P and space. The input will not necessarily contain all three characters.

#: A wall
P: A prisoner
space: An empty space

An example input will look like:
#####
#   #
# P #
#   #
#####

Output
A truthy/falsey value of whether or not the prison is secure. The prison is only secure if it can hold all of the prisoners. If any prisoner can escape it is not secure.
A prisoner can escape if they are not fully enclosed by a wall. A diagonal joining is fully enclosed.
Test cases
############# Truthy
# P #  P#   #
#   #   # P #
#############

############# Truthy
# P    P    #
#   #   # P #
#############

############# Falsey
# P #  P#   #
#   #   # P #
########## ##

####          Truthy
#   #
 #   #
  # P ####
  ####

P             Falsey

###           Falsey
# #
# #
### P

I have a feeling this is a duplicate or at least a similar challenge. Good challenge anyways.

May we require that the input be padded to a rectangle?

@JanDvorak You can have leading and trailing whitespace yes.

@JanDvorak It might be but with my limited Google Fu I could not find a duplicate.

@JanDvorak It also looks very familiar to me. I think I've seen a similar challenge in the Sandbox before, iirc.

Could you add a test case where we have a closed box, but with a prisoner outside it? I.e. ####\n#  #\n#  #\n####  P

@KevinCruijssen Added

@JanDvorak Aren't you thinking about the challenge where you had to plan the layout of the prison? Can't find it anymore but I remember it well.

I would personally move the prisoner in the third test case one place to their right so that they no longer have a direct vertical path to freedom.

Somehow  related

related (Flood-fill a 2D grid)

It would be good to have Falsey examples where both horizontal and vertical movement are required to escape.

I wonder if there's any convenient way to interpret this input as a bitmap and use an image editor's flood fill tool on it.

Possible duplicate of Thinking outside the box - Am I doing it right?

@tfbninja Not really a duplicate. That one asks to try to have the program extrapolate from given data to determine if the word is in the box. This one is BFS floodfill to see if there are unenclosed spaces holding marked values.

@tfbninja Certainly not a duplicate. The other question also restrict the wrapper to be in the shape of a box, and only give partial information. Still, useful as related.

@HyperNeutrino and user202729 I see your point, I will remove my close vote

Snails, 13 bytes
!(t\P(o\ ),o~

Try it online!
Prints 0 for insecure prisons and the size of the input's bounding box for secure prisons.
The idea is to ensure that we can't find a path from a P to an out of bounds cell (~) moving only orthogonally (o) through spaces. The t is a teleport so that regardless where we attempt the match it tries all possible starting positions to find a P.

The right tool.

C# (.NET Core), 485 480 474 470 421 408 bytes
The absolutely wrong tool and approach, but nonetheless...

7 bytes (and more) saved with the useful tips from TheLethalCoder.
4 bytes saved by returning an integer.
4 more bytes saved thanks (once again) to TheLethalCoder by replacing ' ' with 32 in the comparisons.
LOTS of bytes saved by refactoring the code.
13 more bytes thanks to (guess who?) TheLethalCoder. :) I keep forgetting his tips and he keeps reminding me them.

m=>{var p='P';int a=m.Length,b=m[0].Length,i=0,j,x,y;var c=new System.Collections.Stack();for(;i<a;i++)for(j=0;j<b;j++)if(m[i][j]==p)c.Push(new[]{i,j});while(c.Count>0){var t=(int[])c.Pop();x=t[0];y=t[1];if(x<1|x>a-2|y<1|y>b-2)return 0;foreach(var v in new[]{-1,1}){var z=x>0&x<a-1&y>0&y<b-1;if(z&m[x+v][y]==32){m[x][y]=p;c.Push(new[]{x+v,y});}if(z&m[x][y+v]==32){m[x][y]=p;c.Push(new[]{x,y+v});}}}return 1;}

Try it online!
Basically I expand the positions of the P's whenever a white space is around until it reaches (or not) the border of the layout.
Some licenses:

I use a char[][] as the input for the layout.
Returns 0 as insecure and 1 as secure.

You can't take extra input to the function so you can assume the dimensions... Unless you can find a meta post to persuade me otherwise.

1>0 and 1<0 are shorter than true and false.

@TheLethalCoder more and more amazed with your tips! I was afraid that the extra parameters were too much, so I changed the answer.

Can ==0 become <1? You have at least 1 byte of irrelevant whitespace. Can you remove the new[]s? (Doesn't always work but sometimes does like in int[] n = {1,2,3};).

Inputting a multidimensional array instead if a jagged one may save you some bytes i.e. char[,] and seeing as you are padding the input to a rectangle anyway it shouldn't be a problem.

@TheLethalCoder if I change char[][] with char[,] then m.Length becomes m.GetLength(0) and m[0].Length becomes m.GetLength(1) which are larger, but maybe the rest of the code gets shorter enough. As for the irrelevant whitespace, I always slip some of them, no matter how much I try... :)

@TheLethalCoder funny, the code remains the same length after the change, so I'll leave it as is. :)

Me too, I've been meaning to create a small tool for removing the whitespace in C# but I've never gotten around to it. And haha unfortunate.

{m[x][y]= p; c.Push(new[] -> {m[x][y]=p;c.Push(new[]

You can compare chars to ints so I believe you can replace the ==' ' to ==32 to save bytes. You should be able to do this on similar comparisons as well.

408: m=>{var p='P';int a=m.Length,b=m[0].Length,i=0,j,x,y;var c=new System.Collections.Stack();for(;i<a;i++)for(j=0;j<b;j++)if(m[i][j]==p)c.Push(new[]{i,j});while(c.Count>0){var t=(int[])c.Pop();x=t[0];y=t[1];if(x<1|x>a-2|y<1|y>b-2)return 0;foreach(var v in new[]{-1,1}){var z=x>0&x<a-1&y>0&y<b-1;if(z&m[x+v][y]==32){m[x][y]=p;c.Push(new[]{x+v,y});}if(z&m[x][y+v]==32){m[x][y]=p;c.Push(new[]{x,y+v});}}}return 1;}

Sorry for all the small improvements but I'm not the best at spotting lots at once...

@TheLethalCoder at first I used the new int[]{-1,1} in two foreach loops, but I reduced them to one and then I forgot to move the array into the declaration of the loop. And once again I forgot to move all the declarations of ints into the same place.

Moving x and y into the main declaration didn't save us any bytes but it's could practice for golfing :)

Perl 5, 69 bytes
-10 bytes thanks to @Grimy.
-2 bytes thanks to @Neil.
77 byte of code + -p0 flags.
/
/;$_=s/(P| )(.{@{-}})?(?!\1)(?1)/P$2P/s?redo:!/\A.*P|P.*\Z|^P|P$/m

Try it online!
Some short explanations:
The idea is to put a P everywhere the prisoners can go. If any P is on the first/last line, or the first/last column, then the prisoners can go there and therefor escape, which means the prison isn't secure.
s/(P| )(.{@{-}})?(?!\1)(?1)/P$2P/s replaces a space on the right of or bellow a P with a P, or a space on the left or on top of a P.
Finally, /\A.*P|P.*\Z|^P|P$/m checks if a line starts or ends with a P, or if there is a P on the first or the last line.

cool approach using regexps! (but probably VERY expensive when the space grows)

Actually, it's not that inefficient. In particular, it doesn't require a lot of backtracking, there are not * or +, the longest match it can do is the size of a line... Now of course if you compare with an approach more manual, based on arrays for instance, then yes it's quite inefficient!

Can you use \A and \Z to avoid having to have a separate regex with the /m modifier?

@Neil Right, thanks! I tend to forget about those assertions because ^ and $ are usually shorter, but here it's useful! :)

-1 byte by using /\n/ instead of /.*/, and @{-} instead of @{+} (where \n means a literal newline).

-6 bytes by merging the two substitutions: s/P(.{@{-}})? | (.{@{-}})?P/P$1$2P/s.

-2 bytes by golfing the merged substitution: s/(P| )(.{@{-}})?(?!\1)(?1)/P$2P/s.

@Grimy very nice golfing of the regex! Thanks :)

JavaScript (ES6), 134 133 bytes
Takes input as an array of arrays of characters. Returns 0 (insecure) or 1 (secure).
f=a=>a.map((r,y)=>r.map((c,x)=>c>'O'&&[-1,1,0,0].map((X,i)=>(R=a[y+1-'1102'[i]])&&R[X+=x]?R[X]<'!'?R[o=2,X]=c:0:o=0)),o=1)|o&2?f(a):o

Test cases

f=a=>a.map((r,y)=>r.map((c,x)=>c>'O'&&[-1,1,0,0].map((X,i)=>(R=a[y+1-'1102'[i]])&&R[X+=x]?R[X]<'!'?R[o=2,X]=c:0:o=0)),o=1)|o&2?f(a):o

console.log(f([
  [...'#############'],
  [...'# P #  P#   #'],
  [...'#   #   # P #'],
  [...'#############']
]))

console.log(f([
  [...'#############'],
  [...'# P    P    #'],
  [...'#   #   # P #'],
  [...'#############']
]))

console.log(f([
  [...'#############'],
  [...'# P #  P#   #'],
  [...'#   #   # P #'],
  [...'########## ##']
]))

console.log(f([
  [...'####'],
  [...'#   #'],
  [...' #   #'],
  [...'  # P ####'],
  [...'  ####']
]))

console.log(f([
  [...'P']
]))

console.log(f([
  [...'###'],
  [...'# #'],
  [...'# #'],
  [...'### P']
]))

Can the &&s just be &?

@TheLethalCoder Not the first one, but the second one can be replaced by |. Thanks!

Didn't know the spread operator worked on strings. Cool!

JavaScript (ES6), 121 bytes
f=s=>s==(s=s.replace(eval('/( |P)([^]{'+s.search`
`+'})?(?!\\1)[ P]/'),'P$2P'))?!/^.*P|P.*$/.test(s)&!/^P|P$/m.test(s):f(s)

Takes input as a newline-delimited rectangular string. Returns 0 for insecure and 1 for secure. Based on my answer to Detect Failing Castles, although it would be more efficient to test for an escaped prisoner at each step, rather than once they'd finished exploring the prison.

APL (Dyalog Classic), 40 bytes
{⊃2≠(××{1⊃⌈/⍵,⍉⍵}⌺3 3)⍣≡(⌽1,⍉)⍣4⊢'# '⍳⍵}

Try it online!
'# '⍳⍵ encode '#', ' ', 'P' as 0 1 2
(⌽1,⍉)⍣4 surround with 1s
(××{1⊃⌈/⍵,⍉⍵}⌺3 3)⍣≡ max-of-neighbours flood fill of non-zero cells
⊃2≠ do we not have a 2 at the top left?

Octave, 64 55 bytes
@(a,z=padarray(a,[1 1]))~nnz(bwfill(z==35,1,1,4)&z>35);

Try it online!
or
Verify all test cases!
Explanation:
z=padarray(a,[1 1])       %add a boundary(of 0s) around the scene
F = bwfill(z==35,1,1,4)   %flood fill the prison starting from the boundary
~nnz(F&z>35);             %if position of at least a prisoner  is filled then the prison is not secure

Stax, 35 bytesCP437
ä¬my■╡╤▲l@┤êr*⌠\¶ƒläå─▄¶√¿ [Uy⌠Só4↔

Try it online!
Surely golfing language without an internal to handle path-finding can do this as well!
Explanation
Uses the unpacked format to explain.
zLz]Y+Mys+y+{{{" P|P ""PP"Rm}Y!My!Mgphh' =
zLz]Y+Mys+y+                                  Surround the original matrix with four borders of whitespaces
            {                      gp         Iterate until a fixed point is found, return the single fixed point
             {              }Y!               Store the block in register Y and execute it
              {" P|P ""PP"Rm                  For each row, flood every space adjacent to a P with P.
                               My!            Transpose the matrix and do the flooding again
                                     hh' =    The final matrix has a space on the upper left corner that has not been flooded by P

SmileBASIC, 154 146 bytes
I was hoping an answer using flood fill would be shorter than this.
DEF S P
FOR J=0TO 1X=1Y=1FOR I=0TO LEN(P)-1GPSET X,Y,-(P[I]=="#")GPAINT X,Y,-1,-J*(P[I]>@A)X=X*(P[I]>"31")+1INC Y,X<2NEXT
NEXT?!GSPOIT(0,0)GCLS
END

Replace 31 with the corresponding ASCII character.


text:
Print a Variable's Name
Write a function (not a full program), so that if the function is called with a single global variable (or your language's closest equivalent) as its argument, it outputs (i.e. prints or returns) the name of that variable. If the argument is not a variable, output a falsey value instead. (You don't have to handle the case where the argument is a variable, but not global.)
There must not be a compile-time connection between the function call and function definition (notably, the function definition cannot be a macro or similar construct that receives arguments in the form of a literal fragment of source code, neither in text nor abstract syntax tree form). That is: in languages which support separate compilation, the program must work even if the function call is compiled first (with no knowledge of the function definition but possibly a type signature or equivalent), then the function definition is compiled afterwards. If the language doesn't have separate compilation, you must nonetheless aim for a similar separation between the call and definition.
If using a compiled language, you may read the compiled form of the complete program from disk, and may assume that the program was compiled with debug information. (Thus, solutions that work by attaching a debugger from a program to itself are allowed.)
Note that this task may not be possible in every language.
Examples:
var apple = "Hello"
p(apple) // apple

var nil = "Nothing"
p(nil) // nil

var SOMETHING = 69
p(SOMETHING) // SOMETHING

function foo(){}
p(foo) // foo

p(3.14159) // false

p(function foo(){}) // false

Comments are not for extended discussion; this conversation has been moved to chat.

Java
String getParamName(String param) throws Exception {
    StackTraceElement[] strace = new Exception().getStackTrace();
    String methodName = strace[0].getMethodName();
    int lineNum = strace[1].getLineNumber();

    String className = strace[1].getClassName().replaceAll(".{5}$", "");
    String classPath = Class.forName(className).getProtectionDomain().getCodeSource().getLocation().getPath() + className + ".class";

    StringWriter javapOut = new StringWriter();
    com.sun.tools.javap.Main.run(new String[] {"-l", "-c", classPath}, new PrintWriter(javapOut));
    List<String> javapLines = Arrays.asList(javapOut.toString().split("\\r?\\n"));
    int byteCodeStart = -1;
    Map<Integer, Integer> byteCodePointerToJavaPLine = new HashMap<Integer, Integer>();
    Pattern byteCodeIndexPattern = Pattern.compile("^\\s*(\\d+): ");
    for (int n = 0;n < javapLines.size();n++) {
        String javapLine = javapLines.get(n);
        if (byteCodeStart > -1 && (javapLine == null || "".equals(javapLine))) {
            break;
        }
        Matcher byteCodeIndexMatcher = byteCodeIndexPattern.matcher(javapLine);
        if (byteCodeIndexMatcher.find()) {
            byteCodePointerToJavaPLine.put(Integer.parseInt(byteCodeIndexMatcher.group(1)), n);
        } else if (javapLine.contains("line " + lineNum + ":")) {
            byteCodeStart = Integer.parseInt(javapLine.substring(javapLine.indexOf(": ") + 2));
        }
    }

    int varLoadIndex = -1;
    int varTableIndex = -1;
    for (int i = byteCodePointerToJavaPLine.get(byteCodeStart) + 1;i < javapLines.size();i++) {
        if (varLoadIndex < 0 && javapLines.get(i).contains("Method " + methodName + ":")) {
            varLoadIndex = i;
            continue;
        }

        if (varLoadIndex > -1 && javapLines.get(i).contains("LocalVariableTable:")) {
            varTableIndex = i;
            break;
        }
    }

    String loadLine = javapLines.get(varLoadIndex - 1).trim();
    int varNumber;
    try {
        varNumber = Integer.parseInt(loadLine.substring(loadLine.indexOf("aload") + 6).trim());
    } catch (NumberFormatException e) {
        return null;
    }
    int j = varTableIndex + 2;
    while(!"".equals(javapLines.get(j))) {
        Matcher varName = Pattern.compile("\\s*" + varNumber + "\\s*([a-zA-Z_][a-zA-Z0-9_]*)").matcher(javapLines.get(j));
        if (varName.find()) {
            return varName.group(1);
        }
        j++;
    }
    return null;
}

This currently works with a few gotchas:

If you use an IDE to compile this it might not work unless it is run as Admin (depending on where the temporary class files are saved)
You must compile using javac with the -g flag. This generates all debugging information including local variable names in the compiled class file.
This uses an internal Java API com.sun.tools.javap which parses the bytecode of a classfile and produces a human readable result. This API is only accessible in the JDK libraries so you must either use the JDK java runtime or add tools.jar to your classpath.

This should now work even if the method is called multiple times in the program. Unfortunately it does not yet work if you have multiple invocations on a single line. (For one that does, see below)
Try it online!

Explanation
StackTraceElement[] strace = new Exception().getStackTrace();
String methodName = strace[0].getMethodName();
int lineNum = strace[1].getLineNumber();

String className = strace[1].getClassName().replaceAll(".{5}$", "");
String classPath = Class.forName(className).getProtectionDomain().getCodeSource().getLocation().getPath() + className + ".class";

This first part gets some general information about what class we're in and what the name of the function is. This is accomplished by creating an exception and parsing the first 2 entries of the stack trace.
java.lang.Exception
    at E.getParamName(E.java:28)
    at E.main(E.java:17)

The first entry is the line that the exception is thrown on which we can grab the methodName from and the second entry is where the function was called from.
StringWriter javapOut = new StringWriter();
com.sun.tools.javap.Main.run(new String[] {"-l", "-c", classPath}, new PrintWriter(javapOut));

In this line we are executing the javap executable that comes with the JDK. This program parses the class file (bytecode) and presents a human-readable result. We'll use this for rudimentary "parsing".
List<String> javapLines = Arrays.asList(javapOut.toString().split("\\r?\\n"));
int byteCodeStart = -1;
Map<Integer, Integer> byteCodePointerToJavaPLine = new HashMap<Integer, Integer>();
Pattern byteCodeIndexPattern = Pattern.compile("^\\s*(\\d+): ");
for (int n = 0;n < javapLines.size();n++) {
    String javapLine = javapLines.get(n);
    if (byteCodeStart > -1 && (javapLine == null || "".equals(javapLine))) {
        break;
    }
    Matcher byteCodeIndexMatcher = byteCodeIndexPattern.matcher(javapLine);
    if (byteCodeIndexMatcher.find()) {
        byteCodePointerToJavaPLine.put(Integer.parseInt(byteCodeIndexMatcher.group(1)), n);
    } else if (javapLine.contains("line " + lineNum + ":")) {
        byteCodeStart = Integer.parseInt(javapLine.substring(javapLine.indexOf(": ") + 2));
    }
}

We're doing a couple different things here. First, we are reading the javap output line by line into a list. Second we are creating a map of bytecode line indexes to javap line indexes. This helps us later to determine which method invocation we want to analyze. Finally we are using the known line number from the stack trace to determine which bytecode line index we want to be looking at.
int varLoadIndex = -1;
int varTableIndex = -1;
for (int i = byteCodePointerToJavaPLine.get(byteCodeStart) + 1;i < javapLines.size();i++) {
    if (varLoadIndex < 0 && javapLines.get(i).contains("Method " + methodName + ":")) {
        varLoadIndex = i;
        continue;
    }

    if (varLoadIndex > -1 && javapLines.get(i).contains("LocalVariableTable:")) {
        varTableIndex = i;
        break;
    }
}

Here we are iterating over the javap lines one more time in order to find the spot where our method is being invoked and where the Local Variable Table starts. We need the line where the method is invoked because the line before it contains the call to load the variable and identifies which variable (by index) to load. The Local Variable Table helps us actually look up the name of the variable based on the index we grabbed.
String loadLine = javapLines.get(varLoadIndex - 1).trim();
int varNumber;
try {
    varNumber = Integer.parseInt(loadLine.substring(loadLine.indexOf("aload") + 6).trim());
} catch (NumberFormatException e) {
    return null;
}

This part is actually parsing the load call to get the variable index. This can throw an exception if the function isn't actually called with a variable so we can return null here.
int j = varTableIndex + 2;
while(!"".equals(javapLines.get(j))) {
    Matcher varName = Pattern.compile("\\s*" + varNumber + "\\s*([a-zA-Z_][a-zA-Z0-9_]*)").matcher(javapLines.get(j));
    if (varName.find()) {
        return varName.group(1);
    }
    j++;
}
return null;

Finally we parse out the name of the variable from the line in the Local Variable Table. Return null if it isn't found although I've seen no reason why this should happen.
Putting it all together
 public static void main(java.lang.String[]);
    Code:
...
      18: getstatic     #19                 // Field java/lang/System.out:Ljava/io/PrintStream;
      21: aload_1
      22: aload_2
      23: invokevirtual #25                 // Method getParamName:(Ljava/lang/String;)Ljava/lang/String;
...
    LineNumberTable:
...
      line 17: 18
      line 18: 29
      line 19: 40
...
    LocalVariableTable:
      Start  Length  Slot  Name   Signature
          0      83     0  args   [Ljava/lang/String;
          8      75     1     e   LE;
         11      72     2   str   Ljava/lang/String;
         14      69     3  str2   Ljava/lang/String;
         18      65     4  str4   Ljava/lang/String;
         77       5     5    e1   Ljava/lang/Exception;

This is basically what we're looking at. In the example code the first invocation is line 17. line 17 in the LineNumberTable shows that the beginning of that line is bytecode line index 18. That is the System.out load. Then we have aload_2 right before the method call so we look for the variable in slot 2 of the LocalVariableTable which is str in this case.

For fun, here's one which handles multiple function calls on the same line. This causes the function to not be idempotent but that's kind of the point. Try it online!

Love this answer. Was thinking of something along the same lines.  One note though, if you include multiple calls in the same line of the program, then it can't determine which one is calling the method (not sure that this can be fixed with your current approach), for example, try moving the System.out.println(e.getParamName(str));System.out.println(e.getParamName(str2));System.out.println(e.getParamName(str4)); onto one line in the TIO link.

You can retrieve the javap location like this: Paths.get(System.getProperty("java.home"), "bin", "javap").

@OlivierGrégoire Thanks but I switched to invoking javap through the internal java api so I don't need to get the exact location on disk in the code anymore (just the classpath)

@PunPun1000 yeah I'm not sure if there's a nice way to fix that while maintaining an idempotent function but I might put something together that just uses state outside the function for fun.

@PunPun1000 Added a version that can handle multiple calls on one line. It's more than just the function so I just added another TryItOnline link rather than updating the answer.

Python 2
This is about the most dirty code I've written but it works. ¯\_(ツ)_/¯ Throws an error on a non-existent variable as Python will immediately dislike you for calling the function with one. Also throws an error on non-variables but this can be fixed with a try/except if needed.
import inspect
import re

def name_of(var):
    for i in inspect.getframeinfo(inspect.currentframe().f_back)[3]:
        return re.search(r'\bname_of\s*\(\s*([A-Za-z_][A-Za-z0-9_]*)\s*\)', i).groups()[0]

Try it online!
If we're allowed to take the argument as a string, this satisfies the requirements of outputting a falsy value on an invalid input.
import inspect
import re

def name_of(var):
    # return var :P

    try:
        eval(var)
    except NameError:
        return False

    for i in inspect.getframeinfo(inspect.currentframe().f_back)[3]:
        try:
            return re.search(r'\bname_of\s*\(\s*[\'"]([A-Za-z_][A-Za-z0-9_]*)[\'"]\s*\)', i).groups()[0]
        except AttributeError:
            return False

Try it online!

You posted almost same answer, while I was typing explanation to mine :D  +1 for you

@DeadPossum Always post and answer and add an explanation later as an edit. ;)

@Arjun, oh great so we have to play EditGolf as well as CodeGolf :P

Mathematica
f[x_] := ValueQ @ x && ToString @ HoldForm @ x
SetAttributes[f, HoldFirst]

The HoldFirst attribute prevents f from evaluating its argument before invoking the function. ValueQ @ x then checks whether the given argument is a variable that has been given a value. If not we just return False due to short-circuiting. Otherwise, we obtain the variable name with ToString @ HoldForm @ x.

Dang, abusing how Mathematica handles And... I like how the right argument of And doesn't even have to be a Boolean expression.

I know it's not code golf, but why not just f[x_] := ValueQ @ x && HoldForm @ x?. If it weren't for the requirement to check if the input is a variable, HoldForm on its own would work.

HoldAll instead of HoldFirst?

@ngenisis Because that returns HoldForm[a] and not "a". While they are displayed the same in the Mathematica notebook, the function exists independently of the frontend, so I wanted to have a solution that returns a string.

@GregMartin This still isn't code golf and with only one argument they're identical as far as I know, so I just picked on e at random.

Request to remove whitespace because...um...  because

@CalculatorFeline request declined.

This doesn't look natural. Mathematica code that isn't an unreadable mess of symbols nor a single builtin?!

Mathematica
f~SetAttributes~HoldAll;
f[_] = False;
f[x_Symbol?ValueQ] := SymbolName@Unevaluated@x;

Mathematica likes to evaluate everything, so to make it stop, we have to fight against it. In its own language.
How?
f~SetAttributes~HoldAll;

Tells Mathematica that whenever function f is called, its arguments shouldn't be evaluated (i.e. held).

f[_] = False;

When f is called with an argument, output False. (?!)

f[x_Symbol?ValueQ] := SymbolName@Unevaluated@x;

When f is called with a defined Symbol (which has a value), output the symbol name of the input.
The previous line does not take precedence, despite being defined earlier, because this definition is more specific. As the Wolfram Documentation states: Mathematica "tries to put specific definitions before more general definitions."
Mathematica is very stubborn and keeps trying to evaluate variables whenever possible. The extra Unevaluated takes care of that.

C#
string n<T>(Expression<Func<T>>m) =>
    (m.Body as MemberExpression)?.Member?.Name ?? null;

Full/Formatted version:
using System;
using System.Linq.Expressions;

class P
{
    static void Main()
    {
        var apple = "Hello";
        var nil = "Nothing";
        var SOMETHING = 69;

        Console.WriteLine(n(() => apple));
        Console.WriteLine(n(() => nil));
        Console.WriteLine(n(() => SOMETHING));
        Console.WriteLine(n(() => 3.14159));

        Console.ReadLine();
    }

    static string n<T>(Expression<Func<T>>m)
        => (m.Body as MemberExpression)?.Member?.Name ?? null;
}

Another way to do this is by reflecting on the type like so:
public static string GetParameterName<T>(T item)
{
    var properties = typeof(T).GetProperties();

    return properties.Length > 0 ? properties[0].Name : null;
}

However, you have to call it like:
GetParameterName(new { apple });

It then also fails for 3.14159 by returning Length and for that you also have to call it like the following instead:
GetParameterName(new double[]{ 3.14159 });

In C# 6.0 we also have:
nameof

But this won't compile if you pass it something that isn't a variable e.g. 3.14159. I believe it also evaluates the input at compile time so it seems like it fails that requirement as well.

This is a bit dodgy... because the lambda stuff is absolutely essential (i.e. you can't just pass in the variable, you have to pass something that the compile will recognise should become an Expression). You should also be counting using System.Linq.Expressions;.

Does this count as "receiving arguments in abstract syntax tree form" though?

@VisualMelon I couldn't find any other way to do this in C# so I did it this way. Also this is not [tag:code-golf] so it doesn't really matter,

... sorry, didn't realise there wasn't a byte count!

R
function(x) if (identical(substitute(x), x)) FALSE else substitute(x)

substitute returns the parse tree for an unevaluated expression. The identical conditional makes sure that this unevaluated expression isn't identical to the expression itself; i.e. that the passed in parameter isn't a literal.

MATLAB
varname = @(x) inputname(1);

Within a function there are a few preset variables like varargin  or nargin, among those we also have inputname.
stolen from here

I never knew this existed. I played around with this a bit, and perhaps you'll like this gem: x=42;y=54; f=@(x)eval(inputname(1));f(x),f(y)

Haha, eval==evil =D (it actually works with x=42;y=54; f=@(x)eval('inputname(1)');f(x),f(y))

Yeah, it's just that an anonymous function does not know about any workspace variable, so eval can only evaluate x, and is then eval-ing the function argument, not the workspace variable.

Python 2
Some research has been done. And it seems to be possible in python, but I still expect some troubles to be found.
Solution is not perfect, as it assumes some structure of the code. Yet I didn't break it still.
import inspect
import re

def get_name(var):
    called = inspect.getouterframes(inspect.currentframe())[1][4][0]
    return re.search('(?<=get_name\().*(?=\))', called).group().lstrip().rstrip()

This uses inspect to look at surround scope and find where function get_name is called.
For example inspect...[1] will return

(< frame object at 0x01E29030>, 'C:/Users/---/PycharmProjects/CodeGolf/Name_var.py', 14, '< module>', ['print get_name(   a  )\n'], 0)

And inspect...[1][4] will show us list with code, where function is called:

['print get_name(   a  )\n']

After that I used regex to retrieve name of the argument
re.search('(?<=get_name\().*(?=\))', called).group()

And .lstrip().rstrip() to remove all whitespaces that may be placed into bracets.
Example with some tricky input

PowerShell
function t($t){(variable($MyInvocation.Line.Split(' $'))[-1]-ea si).Name}

$apple = 'hi'
t $apple
apple

t 3.141

But it doesn't work reliably, it's rudimentary.

This is not code golf.

@Okx oh, oops, so it's not.

JavaScript (ES6)
For all property names in window (Object.getOwnPropertyNames(w)), attempt to define a getter for that property that returns the property name.
Then, add an entry to a Map M where the key is the (possibly overridden) value of the property, and the value is the name of the property.
The function f simply takes a variable (i.e. a property of window) and returns the entry in M for that value.
let
    w = window,
    M = new Map(),
    L = console.log,
    P = Object.getOwnPropertyNames(w),
    D = Object.defineProperty

for(const p of P){
    try {
        D(w, p, {
            get(){
                return p
            }
        })
    } catch(e){ L(e) }

    try {
        M.set(w[p], p)
    } catch(e){ L(e) }
}

let f = v => M.get(v)

This works for all built-in global variables except window itself, as there is no way to distinguish it from top (unless run in a frame):
L( P.filter(p => p !== f(w[p])) )
// -> ['window']

For some reason, I am getting an error: L not a function. Why would that happen?

Wow! That's deeper into ES6 than I've seen in a while.

@CalebKleveter D'oh! I forgot a comma on the second line. That may or may not have been problematic.

PHP
Needs that the variable value is unique in the array of the global variables

function v($i){echo"$".array_search($i,$GLOBALS);}

Try it online!
PHP, 96 bytes
function v($i){
echo($i==end($g=$GLOBALS))?"$".key(array_slice($g,-1)):0;
}
$hello=4;
v($hello);

Try it online!
Needs that the variable is initialized directly to the function call.
Checks if the last global variable is equal surrendering variable

This is not code golf.

@Okx I know In the moment I have no better idea.

Fails when two variables have the same value

Perl 5 + Devel::Caller
use 5.010;
use Devel::Caller qw/caller_vars/;
use Scalar::Util qw/refaddr/;

sub v {
   # find all operands used in the call, formatted as variable names
   my @varsused = caller_vars(0,1);
   scalar @varsused == 1 or return; # exactly one operand, or return false
   $varsused[0] =~ s/^\$// or return; # the operand actually is a variable
   # it's possible we were given an expression like "~$test" which has only
   # one operand, but is not a variable in its own right; compare memory
   # addresses to work this out
   refaddr \ ($_[0]) == refaddr \ (${$varsused[0]}) or return;
   return '$' . $varsused[0];
}

# some test code

our $test = 1;
our $test2 = 2;
our $test3 = 3;

say v($test2);
say v(2);
say v(~$test3);
say v($test);
say v($test + 1);
say v(++$test);
say v($test3);

We use Devel::Caller (a debugger-like module) to walk the call stack, looking for the call to the function, and return all the operands within the argument, returning them as variable names. If there's more (or less) than one operand, we weren't called with a variable. If the operand wasn't a variable, it won't have a name and we can detect that too.
The trickiest case is if we get a one-operand expression involving a variable, such as ~$x. We can figure out if this has occurred by taking a reference to the variable directly from the symbol table (using the ${…} symbolic reference syntax) and comparing its memory address to the value we were passed as an argument (which is, conveniently, passed by reference). If they're different, we have an expression rather than a lone variable.
Note that if we call this function with a preincrement or predecrement expression on a single variable, as in v(--$x), we get $x returned. This is because it's actually the variable itself that's being passed to the function in this case; it just gets incremented or decremented beforehand. I hope this doesn't disqualify the answer. (In a way, it makes it better, because it shows that we're checking the argument itself rather than just reading the source code.)

PHP
While the other PHP submissions only test if the given value matches a value of a global, this version works by taking a reference to the value:
// take a reference to the global variable
function f(&$i){
  foreach(array_reverse($GLOBALS) as $key => $value)
    if($key != 'GLOBALS') {
      // Set the value of each global to its name
      $GLOBALS[$key] = $key;
    }

  foreach($GLOBALS as $key => $value)
    if($key != 'GLOBALS' && $key != $value) {
      // The values mismatch so it had a reference to another value
      // we delete it
      unset($GLOBALS[$key]);
      // and update the value to its name again
      $GLOBALS[$key] = $key;
    }

  echo '$', is_array($i) ? 'GLOBALS' : $i, "\n";
}

This should now work even if the global variable is a reference to another value at the time of calling.
Test it here.

Great and Thank You very much for the learning effort

@JörgHülsermann Even found a way to improve it !

Röda
f(&a...) {
	a() | name(_) | for str do
		false if [ "<" in str ] else [str]
	done
}

Try it online!
Röda has a builtin function for this – name. Unfortunately, though, it doesn't return a falsy value when not given a variable.
This code abuses several features of reference semantics. Explanation line by line:
f(&a...) {
The function takes a variable number of reference arguments (&a...). This is the only way in Röda to create a list of references.
a() | name(_) | for str do
At the second line the elements of a are pushed to the stream (a()). These elements are references if the function was given variables and normal values otherwise.
The elements are iterated using an underscore loop. The underscore syntax is syntax sugar for for loops, so name(_) is equivalent to name(var) for var. The name of the variable used in the for loop is of form <sfvN> where N varies. (Ie. "name(<sfv1>) for <sfv1>") It is illegal for a user-defined variable to contain < or >, so the generated names don't collide with existing variable names.
The name() function returns the name of the given variable. If the element in a being iterated is a reference, then it is the variable given to name. Otherwise, if the element was a normal value, the variable given to name is the underscore variable <sfvN>. This is due to the semantics of references in Röda: if a function accepts a reference and the function is passed a reference variable, the passed value does not point to the reference variable but to the variable the reference variable points to.
false if [ "<" in str ] else [str]
At the third line we examine if the variable name in the stream contains a < character. If so, it is an underscore variable and the value passed to f was not a reference. Otherwise we output the name of the reference.
This solution does not work if the variable given to the function is a reference or an underscore variable. However, the question specifies that only global variables must be handled, and they can't be references or underscore variables in Röda.

PHP
function f($v){foreach($GLOBALS as$n=>$x)$x!=$v?:die($n);}

if value is found, print variable name and exit. print nothing and don´t exit else.
61 bytes to return variable name or NULL:
function f($v){foreach($GLOBALS as$n=>$x)if($x==$v)return$n;}

It will not find named functions, only those assigned to variables.
And a PHP function cannot detect wether a parameter was provided by reference or by value. The function will just return the first name where the value matches the function parameter value.
Test it online

Ruby, 46 bytes
Feels like the dirtiest code I've ever written for Ruby.
Requires that the global variables you call has a unique value that isn't on any other global variable, because the only way to do this challenge in Ruby is to do an search on all global variables and return the first match. OP says it's ok, and is free to judge if my solution is valid.
Note that global variables start with $ in Ruby, for if you want to add extra test case stuff.
->v{global_variables.find{|n|eval(n.to_s)==v}}

Try it online!

PowerShell
New version but works starting from PowerShell 3.0
function p{[scriptblock]::create($myinvocation.line).ast.findall({$args[0]-is[Management.Automation.Language.VariableExpressionAst]},0)[0]|% v*h|% u*|%{($_,!1)[!$_]}}

Try It Online!
Previous version
function p{$t=[management.automation.psparser]::tokenize($myinvocation.line,[ref]@())|? type -match '^[cv]'|? start|% content;($t,!1)[!$t]}

Try It Online!

tcl
proc p a {puts [subst $a]}

demo

JavaScript (ES6)
Requires that the value of the variable passed to the function is unique to that variable. Returns undefined if a variable wasn't passed.
arg=>{
    for(key in this)
        if(this[key]===arg)
            return key
}

Try it
For some reason, it throws a cross-origin error in a Snippet when a "literal" is passed.

var fn=
    arg=>{
        for(key in this)
            if(this[key]===arg)
                return key
    },
str="string",
int=8,
arr=[1,2,3],
obj={a:1}
console.log(fn(fn))
console.log(fn(str))
console.log(fn(int))
console.log(fn(arr))
console.log(fn(obj))

Explanation
Loop through all the entries in the global object (this), checking if the value of each one is strictly equal to the value of the argument passed to the function. If a matching entry is found then its key (name) is returned, exiting the function.

Alternative
With the same requirements as above
arg=>
    [...Object.keys(this)].filter(key=>
        this[key]==arg
    ).pop()

I think this fails if two globals have the same value.

I am getting some very weird output.

@MartinEnder; yes, it assumes that the value assigned to the variable passed is unique to that variable; forgot to include that when I posted.

@CalebKleveter; some of those are due to the fact that the value of the variable you're passing isn't unique to that variable and some of it is due to invalid variable names (e.g., hello--). Also, you'd need to use var rather than let.

Why does let not work? And I am rather confused about what caused the output from the google var.

@CalebKleveter, see here for more info on the difference in scoping between let and var. To your second question: That happened because you have a variable named IN_GLOBAL_SCOPE within your global scope and it has a value of 1. You can check the existing variables in your global scope and their values by running this before testing the above: for(x in this)console.log(x+": "+this[x])

@CalebKleveter : I have no idea if it is relevant here (I haven't started learning javascript yet) but maybe top-javascript-pitfalls can help?

Here's my JavaScript attempt.


text:
What is the area of this polygon?
Calculate the area of a polygon.
Inspired by this shoelace algorithm video.
Task
Your job is to create a program or function that calculates the area of a polygon. Program or function is defined according the the default definition in meta.
Input
You will receive the X and Y coordinates of each vertex of the polygon. You can take the input as a list of tuples ([[x1, y1], [x2, y2], etc]), a matrix, or a flat list ([x1, y1, x2, y2, etc]). Two lists containing x and y coordinates respectively are allowed as well. The vertices are numbered counterclockwise and the first vertex is the same as the last vertex provided, thus closing the polygon.
If you want you can take the input without the last vertex (so receive each coordinate just once).
You can assume that the edges of the polygons don't intersect. You can also assume that all vertices have integer coordinates.
Output
The area of the polygon. All standard output methods are allowed. If your language does not allow for float division and the solution would not be an integer, you are allowed to return a fraction. The fraction does not necessarily have to be simplified, so returning 2/4 would be allowed.
Winning criterium
Shortest code wins!
Test cases
[[4,4],[0,1],[-2,5],[-6,0],[-1,-4],[5,-2],[4,4]]
55

[[1,1],[0,1],[1,0],[1,1]]
0.5
1/2

Is input like [x1, x2, x3], [y1, y2, y3] allowed?

@programmer5000 and Martin Ender , yes, I'll edit it in :)

I agree, voted to reopen.

@flawr I made that a dupe of this. It is not really a dupe of its dupe target, which to apply the same method as here recursively would require finding the vertices that are crossing points and would require ordering the resulting subsets into counter-clockwise fashion - that seems much more complex.

Jelly,  8  6 bytes
-1 byte thanks to Emigna (redundant €, ÆḊ has a left-depth of 2)
-1 byte thanks to Emigna, again (halve, H, is floating point no need to ÷2)
ṡ2ÆḊSH

A monadic link taking a list of pairs of coordinates in counter-clockwise fashion as per the examples (with the one repeat) and returning the area.
Try it online!
How?
Applies the shoelace algorithm, just as described in the video (which I happened to also watch just the other day!)
ṡ2ÆḊSH - Link: list of [x,y] coordinate pairs anticlockwise & wrapped, p
ṡ2     - all overlapping slices of length 2
  ÆḊ   - determinant (vectorises)
    S  - sum
     H - halve

The second test-case returns  -0.5 for me :o

Oh, I'll have to check it out...

That's because as [x,y] coordinates they are given clockwise rather than counter-clockwise. An input of [[1,1],[0,1],[1,0],[1,1]] will return a 0.5.

Woops, I'll edit that :D

I don't think you need € right?

@Emigna Ah yes, good catch!

Also, H instead of ÷2

Mathematica, 13 bytes
Area@*Polygon

Could it get more trivial?

@Mr.Xcoder Sure.

o_O - I am literally mindblown...

That's Mathematica for you. Every conceivable thing is built in to the language.

Octave, 9 bytes
@polyarea

Inputs are a vector with the x values and a vector with the y values. This works in MATLAB too.
Try it online!

JavaScript (ES6),  69 67 47  44 bytes
Thanks to @Rick for noticing that we don't need the absolute value if the vertices are guaranteed to be sorted in counterclockwise order and for suggesting to take a flat list as input, saving 20 bytes!
Saved 3 more bytes thanks to @Shaggy
Takes input as a flat list of vertices, including the last vertex.
f=([x,y,...a])=>a+a?x*a[1]/2-y*a[0]/2+f(a):0

Try it online!
How?
This is based on the formula used in many other answers. For \$n\$ 0-indexed vertices:
$$area=\left|\frac{(x_0y_1-y_0x_1)+(x_1y_2-y_1x_2)+\ldots+(x_{n-1}y_0-y_{n-1}x_0)}{2}\right|$$

Very impressive! Could you explain how it works?

The vertices in the second test case were mistakenly ordered incorrectly. The abs shouldn't be necessary.

You can also save 7 bytes switching to a flat list: a=>(g=([x,y,...a])=>1-a?0:x*a[1]-y*a[0]+g(a))(a)/2

@Rick is right - abs isn't necessary. Without it the formula calculates the signed area, which is positive because the vertices are given in the counterclockwise order.

@Rick Thanks! Updated ... about 10 months later :/

Would a+a work instead of 1/a[0]?

@Shaggy Wow. This code is old... Thank you!

Python 3, 72 71 bytes
from numpy import*
g=lambda x,y:(dot(x[:-1],y[1:])-dot(x[1:],y[:-1]))/2

Takes two lists, as it was allowed in the comments
x = [x0,x1,x2, ...]
y = [y0,y1,y2, ...]

Try it online!
This is basically just the implementation of the shoelace-formula.
May I get plus points for a golf that you actually would implement like that? :D
-1, there is no need for a space behind x,y:.

Taking two lists is also mentioned in the body of the question now :)

@JarkoDubbeldam Uh, I just saw, that it has to output the area. This solution currently just returns the area.
Is that allowed as well, or shall it be printed?

A function returning a value counts as output :)

I think that with python you don't even have to name the function, so just starting with lambda x,y: is fine.

@JarkoDubbeldam Are there anywhere rules for each language?

I don't think there are rules for each language separately, but rather rules that apply to certain types of programs. I'll try and see if I can find specifics.

https://codegolf.meta.stackexchange.com/a/2456/59530 https://codegolf.meta.stackexchange.com/a/9032/59530

@JarkoDubbeldam That would be great, as I am new to this.

@P.Siehr https://codegolf.meta.stackexchange.com/a/11925/20260

R, 54 52 bytes
pryr::f({for(i in 2:nrow(x))F=F+det(x[i-1:0,]);F/2})

Which evaluates to the function:
function (x)
{
    for (i in 2:nrow(x)) F = F + det(x[i - 1:0, ])
    F/2
}

Makes use of the predefined F = FALSE = 0. Implements the shoelace algorithm in the linked video :)
-2 bytes thanks to Giuseppe

-1 byte for i+-1:0 as the row index

@Giuseppe Nice. I'll remove the + as well ;)

Mathics, 31 bytes
Total[Det/@Partition[#,2,1]/2]&

Try it online!

Mathematica, 25 bytes
Tr@BlockMap[Det,#,2,1]/2&

Factor, 35 bytes
[ dup pick [ rest v. ] 2bi@ - 2 / ]

Try it online!
Takes two arrays of x- and y-coordinates on the top of the stack, and returns the area as an integer or a rational.
Exploits the vector dot product v. which ignores excess elements on either side, so calculating one side of the shoelace is as simple as "remove the first element from the top array, and compute the dot product". And we can reuse it to evaluate the other side of the shoelace by simply swapping the two input arrays.
Honorable mention goes to the Apply combinator 2bi@, which lets us simplify multi-application of the inner function.
Input:
{ 4 0 -2 -6 -1  5 4 }
{ 4 1  5  0 -4 -2 4 }
Remove the first element from top:
{ 4 0 -2 -6 -1 5 4 }
{ 1 5  0 -4 -2 4 }
Evaluate the dot product (sum of elementwise product, ignoring any excess element)

[                  ! Input: ( x y )
  dup pick         ! Copy stack items to form ( x y y x )
  [ rest v. ]      ! The function that evaluates one side of shoelace
  2bi@             ! Apply the above to ( x y ), then to ( y x )
  - 2 /            ! Subtract the two and halve
]

J, 12 bytes
Assuming the input is a list of 2 element lists (ie, a table)
-:+/-/ .*2[\

2[\ -- breaks it down into the shoelace Xs, ie, overlapping squares of 4 elms
-/ .* -- the determinant of each
+/ -- sum it
-: -- divide by 2

If we get the input as a single list, we need to first transform into a table, giving us 20 bytes:
-:+/-/ .*2[\ _2&(,\)

"Assuming the input is a list of 2 element lists (ie, a table)" This is allowed :)

MS-SQL, 66 bytes
SELECT geometry::STPolyFromText('POLYGON('+p+')',0).STArea()FROM g

MS SQL 2008 and higher support Open Geospatial Consortium (OGC)-standard spatial data/functions, which I'm taking advantage of here.
Input data is stored in field p of pre-existing table g, per our input standards.
Input is a text field with ordered pairs in the following format: (4 4,0 1,-2 5,-6 0,-1 -4,5 -2,4 4)
Now just for fun, if you allowed my input table to hold Open Geospatial Consortium-standard geometry objects (instead of just text data), then it becomes almost trivial:
--Create and populate input table, not counted in byte total
CREATE TABLE g (p geometry)
INSERT g VALUES (geometry::STPolyFromText('POLYGON((5 5, 10 5, 10 10, 5 5))', 0))

--23 bytes!
SELECT p.STArea()FROM g

JS (ES6), 98 95 94 93 88 86 82 81 77 73 bytes
(X,Y)=>{for(i in X){a+=(X[i]+X[i-1])*(Y[i]-Y[i-1]);if(!+i)a=0}return a/2}

Takes input like [x1, x2, x3], [y1, y2, y3], and skips the repeated coord pair.
-3 bytes thanks to @JarkoDubbeldam
-4 bytes thanks to @JarkoDubbeldam
-1 byte thanks to @ZacharyT
-4 bytes thanks to @ZacharyT
-4 bytes thanks to @Rick

Haskell, 45 bytes
(a:b:c)?(d:e:f)=(a*e-d*b)/2+(b:c)?(e:f)
_?_=0

Try it online!

APL (Dyalog Extended), 14 bytes
2÷⍨1⊥2-/⍤×∘⌽/⊢

Try it online!
Same formula as in Arnauld's answer.
Takes input as a list of points, sorted in counterclockwise order.
Explanation
2÷⍨1⊥2-/⍤×∘⌽/⊢
             ⊢ take the input (list of pts)
     2      /  reduce overlapping pairs by the following function:
         ×       multiply the first
          ∘⌽     with the second reversed
      -/⍤        reduce the multipled pair by subraction
   1⊥          sum the resultant array (using decoding)
2÷⍨            halve it

PARI/GP 61 bytes
c=concat;s(z,v=1)=c(z,z)[^#x*2]+c(z[^1],z)*v
s(x,-1)*s(y)~/4

assumes coordinates given by two vectors x=[x1,...xn], y=[y1,...,yn]
Test cases
A(x,y)={my(c=concat,s(z,v=1)=c(z,z)[^#x*2]+c(z[^1],z)*v);s(x,-1)*s(y)~/4};
A([1, 0, 1, 1],[1, 1, 0, 1])
1/2
A([4,0,-2,-6,-1,5,4],[4,1,5,0,-4,-2,4])
55

PHP, 76 75 73 bytes
Well, i probably shoot myself in the knee with PHP and his $ prefix for variable but i just wanna try the challenge with it anyway.
Header just remove error reporting for conviniance and format input as 2 array like it's allowed in post... i was just lazzy to retype it myself XD. (you can test both case by switching var in the for loop)
Edit: Figure out i can pass 2 arg to for() and save carac from while  keyword with the same logic
Edit : Saved 2 bytes by reverse the iteration order and use juste $i for condition, saved <0 (need to substract for 2nd option since result will be negative otherwise, but same bytes length)
for($i=count($x);$i;){$s-=$x[$j=$i--]*$y[$i]-$y[$j]*$x[$i];}$s=abs($s)/2;

Try it online!
PHP, 67 66 64 bytes
Solution without the abs() who work on both given case but feel like cheat since can return negative values in some cases ^^'
for($i=count($x);$i;){$s-=($x[$j=$i--]*$y[$i]-$y[$j]*$x[$i])/2;}

Try it online!

Welcome to Code Golf, and nice answer! Don't worry about $s being ungolfy, scoring is by language here.

Perl 5 -pa, 62 bytes
map$\+=$F[$i]*($a[($i+1)%@a]-$a[$i++-1]),@a=eval<>}{$\=abs$\/2

Try it online!
Takes input as a list of X coordinates on the first line followed by a list of Y coordinates on the second.

R, 51 46 bytes
Edit: save 5 more bytes since no need to take abs() if points always encircle the polygon in counter-clockwise fashion
pryr::f(sum(x*(1:0-.5)*x[2:1,c(2:ncol(x),1)]))

Try it online!
After 3 years, 1 6 bytes shaved from the previously-best R solution!

Python 3, 58 bytes
lambda x,y:sum(x[i-1]*(j-y[i-2])/2for i,j in enumerate(y))

Try it online!
Implementation of the shoelace algorithm.

Excel, 97 bytes
=LET(a,A1#,x,ROW(a),y,{2,1},b,IF(x=ROWS(a),INDEX(a,1,y),INDEX(a,x+1,y)),SUM(MMULT(a*b,{1;-1}))/2)

LET and dynamic arrays were not Excel features in 2017.

It may be worth noting that the input has to be an array in a formula like this ={4,4;0,1;-2,5;-6,0;-1,-4;5,-2;4,4}