How to programatically determine if my Arduino is running from USB power or VIN?

One one Uno:

USB:

5096
5096
5120
5120
5096
5096
5096
5096

9V in:

5073
5073
5073
5073
5073
5073
5073
5073

On another one:

USB:

5028
5028
5028
5028
5028
5028
5028
5028

9V in:

5006
4984
4984
5006
4984
4984
4984
4984
4984

I don't think you will be able to get the "magic number" using this method. Not for a series of boards.