text:
Is the number binary-heavy?
An integer is binary-heavy if its binary representation contains more 1s than 0s while ignoring leading zeroes. For example 1 is binary-heavy, as its binary representation is simply 1, however 4 is not binary heavy, as its binary representation is 100. In the event of a tie (for example 2, with a binary representation of 10), the number is not considered binary-heavy.
Given a positive integer as input, output a truthy value if it is binary-heavy, and a falsey value if it is not.
Testcases
Format: input -> binary -> output
1          ->                                1 -> True
2          ->                               10 -> False
4          ->                              100 -> False
5          ->                              101 -> True
60         ->                           111100 -> True
316        ->                        100111100 -> True
632        ->                       1001111000 -> False
2147483647 ->  1111111111111111111111111111111 -> True
2147483648 -> 10000000000000000000000000000000 -> False

Scoring
This is code-golf so fewest bytes in each language wins

What if my language can't handle the last test case because it's outside the bounds of what's considered a positive integer?

@musicman523 afaik Standard I/O rules state that you only have to accept numbers representable by your language's number format. Note that "gaming" this by using something like boolfuck is considered a Standard Loophole

Does any truthy/falsy value count or do we need two distinct values?

@EriktheOutgolfer any value

Aka A072600, if this helps anybody.

What about 0?  Is it an allowed input, and if so, is it considered non-heavy?  It's kind of a degenerate case.  Oh nvm, you said positive, which rules out 0.

I will call such numbers "flaggy".

@IllidanS4 just make sure you don't miss out the l

x86 Machine Code, 15 14 bytes
F3 0F B8 C1 0F BD D1 03 C0 42 2B D0 D6 C3

This is a function using Microsoft's __fastcall calling convention (first and only parameter in ecx, return value in eax, callee is allowed to clobber edx), though it can trivially be modified for other calling conventions that pass arguments in registers.
It returns 255 as truthy, and 0 as falsey.
It uses the undocumented (but widely supported) opcode salc.
Disassembly below:
;F3 0F B8 C1
  popcnt eax, ecx ; Sets eax to number of bits set in ecx

;0F BD D1
  bsr edx, ecx    ; Sets edx to the index of the leading 1 bit of ecx

;03 C0
  add eax, eax

;42
  inc edx

;2B D0
  sub edx, eax

  ; At this point,
  ;   edx = (index of highest bit set) + 1 - 2*(number of bits set)
  ; This is negative if and only if ecx was binary-heavy.

;D6
  salc           ; undocumented opcode. Sets al to 255 if carry flag
                 ; is set, and to 0 otherwise.

;C3
  ret

Try it online!
Thanks to Peter Cordes for suggesting replacing lzcnt with bsr.

Nice.  I'd got as far as the obvious popcnt before scrolling down to look at answers, but hadn't thought of lzcnt for dealing with only the significant digits as required by the question.

Is there any way to get a net savings from using bsr instead of lzcnt (aka rep bsr)?  You'd have to use sub instead of lea since it gives you 32-lzcnt.  (Or leaves the dst unmodified for src=0, on all existing Intel and AMD hardware.  AMD even documents this behaviour, but Intel says undefined...  Anyway, OP said positive, which rules out 0.)

I was definitely thinking along the same lines as @Peter, since the challenge does explicitly limit inputs to positive integers. In fact, I had a solution drafted using popcnt and bsr, but it was 17 bytes. I was thinking that was pretty good compared to the first asm answer I saw, but this clever lea trick beats the pants off of that. I also looked at comparing bsf and popcnt. But I'm not seeing any way this solution can be beat, even taking into account the 1 byte that you could save by dropping the rep prefix.

salc isn't equivalent to setc al: the latter sets al to 1 if CF set, not to 255.

@Ruslan: Indeed, my mistake. Fixed now.

The actual equivalent of salc is sbb al, al, but you get a savings of 1 byte to encode it. By the way, it is documented by AMD, and it's widely supported by Intel, with the mnemonic even coming from Intel's P6 opcode map. So this one is actually pretty safe to use. Also, nice improvement here to think to use that instruction! This is basically what my original draft did, except (1) I'd used x86-64 code, so inc was twice as long to encode, and (2) I hadn't thought of salc, so I was doing the same work in a longer way. Too bad I can only upvote once.

For the record, bsr = 31 - lzcnt, not 32 - lzcnt.  (I think you got the code right, I'm just correcting my earlier comment.)

Jelly, 5 bytes
Bo-SR

Yields non-empty output (truthy) or empty output (falsy).
Try it online!
How it works
Bo-SR  Main link. Argument: n

B      Binary; convert n to base 2.
 o-    Compute the logical OR with -1, mapping 1 -> 1 and 0 -> -1.
   S   Take the sum s. We need to check if the sum is strictly positive.
    R  Range; yield [1, ..., s], which is non-empty iff s > 0.

Nice. I had Bo-S, but I couldn't find a 1-byte atom that would convert positive/non-positive into truthy/falsy...

Logical or with −1, right?

@Lynn Yes, indeed. Thanks.

4 bytes

@cairdcoinheringaahing Thanks, but Æṃ didn't exist back then.

Dennis is laying down the law :P

Python 2, 35 bytes
lambda n:max('10',key=bin(n).count)

Try it online!
Old answer, 38 bytes
Outputs 0 as falsy and -2 or -1 as truthy

lambda n:~cmp(*map(bin(n).count,'10'))

Try it online!

Does the leading 0 in the return of bin cause this solution problems?

@shadow There is no problem, because of the way max works. In the event of a tie, max will return the first value in the iterable that has the maximal value. This code uses that fact to make sure that 1 is returned in the event of a tie, which actually means there are more ones than zeros, since an extra zero was added by bin. It would actually be incorrect when written this way if not for the extra zero.

@FryAmTheEggman this is also true on the old answer, where the cmp returns 0 when they are both equals

Octave, 18 bytes
@(n)mode(de2bi(n))

TIO doesn't work since the communications toolbox is not included. It can be tested on Octave-Online.
How this works:
de2bi converts a decimal number to a binary numeric vector, not a string as dec2bin does.
mode returns the most frequent digit in the vector. It defaults to the lowest in case of a tie.
@(n)                % Anonymous function that takes a decimal number as input 'n'
    mode(        )  % Computes the most frequent digit in the vector inside the parentheses
         de2bi(n)   % Converts the number 'n' to a binary vector

Is the communications toolbox a standard part of Octave, or is it more akin to a library in other languages?

It's a package that comes with the installation. You have to specifically load it in some installations, and it's automatically loaded as standard in others. It's part of the standard on Octave-Online.net, so I'm using that as a reference. (The code must work in at least one interpreter that existed prior to the challenge).

MATL, 3 bytes
BXM

Try it online!
I don't really know MATL, I just noticed that mode could work in alephalpha's Octave answer and figured there was some equivalent in MATL.
B   ' binary array from input
 XM ' value appearing most.  On ties, 0 wins

JavaScript (ES6), 36 34 bytes
f=(n,x=0)=>n?f(n>>>1,x+n%2-.5):x>0

f=(n,x=0)=>n?f(n>>>1,x+=n%2-.5):x>0 for 35 bytes.

Use n>>1 instead of n>>>1 to save a byte since input is never negative.

@kamoroso94 Thanks, but then it would fail on 2147483648.

@ETHproductions Darn, and n/2|0 is no better :/

Mathematica, 22 bytes
Saved one byte thanks to @MartinEnder and @JungHwanMin.
#>#2&@@#~DigitCount~2&

I think infix notation has higher precedence than @@.

-1 byte (as @MartinEnder noted): #>#2&@@#~DigitCount~2&

Brachylog, 6 bytes
ḃọtᵐ>₁

Try it online!
Explanation
Example input: 13

ḃ        Base (default: binary): [1,1,0,1]
 ọ       Occurences:             [[1,3],[0,1]]
  tᵐ     Map Tail:               [3,1]
    >₁   Strictly decreasing list

Since ḃ will never unify its output with a list of digits with leading zeroes, we know that the occurences of 1 will always be first and the occurences of 0 will always be second after ọ.

Python 3,  44  (thanks @c-mcavoy) 40 bytes
lambda n:bin(n).count('0')<len(bin(n))/2

Try it online!

Crossed out 44 is still 44

Regex (ECMAScript), 183 bytes
This was another interesting problem to solve with ECMA regex. The "obvious" way to handle this is to count the number of 1 bits and compare that to the total number of bits. But you can't directly count things in ECMAScript regex – the lack of persistent backreferences means that only one number may be modified in a loop, and at each step it can only be decreased.
This unary algorithm works as follows:

Take the square root of the largest power of 2 that fits into N, and take note of whether the square root was perfect or had to be rounded down. This will be used later.
In a loop, move each most-significant 1 bit to the least-significant position where there is a 0 bit. Each of these steps is a subtraction. At the end of the loop, the remaining number (as it would be represented in binary) is a string of 1s with no 0s. These operations are actually done in unary; it's only conceptually that they are being done in binary.
Compare this "binary string of 1s" against the square root obtained earlier. If the square root had to be rounded down, use a doubled version of it. This ensures that the "binary string of 1s" is required to have more than half as many binary digits as N in order for there to be a final match.

To obtain the square root, a variant of the multiplication algorithm briefly described in my Rocco numbers regex post is used. To identify the least-significant 0 bit, the division algorithm briefly described in my factorial numbers regex post is used. These are spoilers. So do not read any further if you don't want some advanced unary regex magic spoiled for you. If you do want to take a shot at figuring out this magic yourself, I highly recommend starting by solving some problems in the list of consecutively spoiler-tagged recommended problems in this earlier post, and trying to come up with the mathematical insights independently.
With no further ado, the regex:
^(?=.*?(?!(x(xx)+)\1*$)(x)*?(x(x*))(?=(\4*)\5+$)\4*$\6)(?=(((?=(x(x+)(?=\10$))*(x*))(?!.*$\11)(?=(x*)(?=(x\12)*$)(?=\11+$)\11\12+$)(?=.*?(?!(x(xx)+)\14*$)\13(x*))\16)*))\7\4(.*$\3|\4)
Try it online!
# For the purposes of these comments, the input number = N.
^
# Take the floor square root of N
(?=
    .*?
    (?!(x(xx)+)\1*$)    # tail = the largest power of 2 less than tail
    (x)*?               # \3 = nonzero if we will need to round this square root
                        #      up to the next power of two
    (x(x*))             # \4 = potential square root; \5 = \4 - 1
    (?=
        (\4*)\5+$       # Iff \4*\4 == our number, then the first match here must result in \6==0
    )
    \4*$\6              # Test for divisibility by \4 and for \6==0 simultaneously
)
# Move all binary bits to be as least-significant as possible, e.g. 11001001 -> 1111
(?=
    (                                 # \7 = tool for making tail = the result of this move
        (
            (?=
                (x(x+)(?=\10$))*(x*)  # \11 = {divisor for getting the least-significant 0 bit}-1
            )
            (?!.*$\11)                # Exit the loop when \11==0
            (?=
                (x*)                  # \12 = floor((tail+1) / (\11+1)) - 1
                (?=(x\12)*$)          # \13 = \12+1
                (?=\11+$)
                \11\12+$
            )
            (?=
                .*?
                (?!(x(xx)+)\14*$)     # tail = the largest power of 2 less than tail
                \13                   # tail -= \13
                (x*)                  # \16 = tool to move the most-significant 1 bit to the
                                      # least-significant 0 bit available spot for it
            )
            \16
        )*
    )
)
\7                  # tail = the result of the move
\4                  # Assert that \4 is less than or equal to the result of the move
(
    .*$\3
|
    \4              # Double the value of \4 to compare against if \3 is non-empty,
                    # i.e. if we had an even number of total digits.
)

-98 bytes

x86_64 machine code, 23 22 21 bytes
31 c0 89 fa 83 e2 01 8d 44 50 ff d1 ef 75 f3 f7 d8 c1 e8 1f c3

Disassembled:
  # zero out eax
  xor  %eax, %eax
Loop:
  # copy input to edx
  mov  %edi, %edx
  # extract LSB(edx)
  and  $0x1, %edx
  # increment(1)/decrement(0) eax depending on that bit
  lea -1(%rax,%rdx,2), %eax
  # input >>= 1
  shr  %edi
  # if input != 0: repeat from Loop
  jnz  Loop

  # now `eax < 0` iff the input was not binary heavy,
  neg %eax
  # now `eax < 0` iff the input was binary heavy (which means the MSB is `1`)
  # set return value to MSB(eax)
  shr  $31, %eax
  ret

Thanks @Ruslan, @PeterCordes for -1 byte!
Try it online!

Is there any particular reason why you use 8d 1f instead of 89 fb?

Also, I think you can replace 75 04 ff c0 eb 02 ff c8 with 8d 44 58 ff.

Not a particular one, no. If I'd do that, the condition would be eax >= 0 or I'm gonna need to flip the ebx register in the loop.

The real question is, is there any particular reason why you're using that abominable AT&T syntax?!? Also, the disassembly and your disassembly both agree that you have add eax, 2+dec eax, but your comments suggest that you want to increment ebx, not eax.

It's what I learned, it's pretty much standard on my platform and in the end it doesn't matter - they're both only syntactic sugar. Fixed now - thanks for pointing out.

Using lea (%rdi), %ebx instead of mov %edi, %ebx is weird.  Both are two bytes, but mov would be more idiomatic (and run faster, so using lea this way is a bad habit for non-code-golf purposes).

You can replace jnz Next/add/dec (7 bytes) with lea -1(%rax, %rbx, 2), %eax (4 bytes) to do eax += 2*ebx - 1 (like in the other x86 machine-code answer).  Then outside the loop, neg %eax (2 bytes) before shifting the sign bit to the bottom.  Net saving of 1 byte.  Or test %eax,%eax / setge %al would also work, if your return value is a bool or int8_t.

BTW, %ebx is call-preserved in the x86-64 System V ABI.  I'm guessing you're aiming for that since you're taking your input in %edi.  You might as well use %edx or %ecx as your scratch reg so this function actually follows the calling convention and can be called directly from C for testing.

shr puts the bit shifted out into CF.  You could use sbb %edx, %edx (2 bytes) to turn that into 0/-1 for use with LEA.  But then the loop structure has to change, because you need to process the last bit shifted out after %edi becomes zero.    Also possible: do something like sbb $-1, %eax to add 1 or 0, or adc $0, %eax to add 0 or 1.  But then the final condition would be different than you get from adding -1 or +1.

Most likely this is an artifact from a previous experiment, was left unchanged and I didn't change it because (for me) code golf isn't about saving a few clock cycles. That's basically the same thing @Ruslan suggested, I tried that and it resulted in the same/more byte count - I'll have a look again. Thanks for your tips!

@PeterCordes I think I know what happened, but I'm not sure: I might have not tried lea -1(%rax,rbx,2) but only lea -1(%eax,%eax,2) and wasted bytes this way.. Anyway, you both were right, I can save a byte like this. Thanks a lot (in return I'll change that lea to a mov while I'm at it)!

isn't about saving a few clock cycles.  In code-golf, it's still a human-readability issue (for the disassembly).  No need to obfuscate for no benefit.  I usually look at compiler-output asm while tuning real code, so lea (%rdi), %ebx just looks bad to my eye.  Runs on fewer ports on most CPUs, and can't be handled in the rename stage with zero latency on IvyBridge+ and AMD Ryzen.  Anyway, re: avoiding address-size prefixes, see also https://stackoverflow.com/questions/34377711/which-2s-complement-integer-operations-can-be-used-without-zeroing-high-bits-in.

Let us continue this discussion in chat.

Any reason you're not using POPCNT? https://www.felixcloutier.com/x86/popcnt it's a 4 byte instruction.  We /are/ talking x86-64, and any new CPU supports it.

@moonheart08: I didn't know about that back then, but someone posted an answer which saved 7 bytes.

R, 54 53 51 bytes
-1 byte thanks to Max Lawnboy
n=scan();d=floor(log2(n))+1;sum(n%/%2^(0:d)%%2)*2>d

reads from stdin; returns TRUE for binary heavy numbers. d is the number of binary digits; sum(n%/%2^(0:d)%%2 computes the digit sum (i.e., number of ones).
Try it online!

Only saw your answer after posting mine... Anyway, you can use log2(n) instead of  log(n,2) to save 1 byte

@MaxLawnboy ah, of course. Thanks!

Golfed off another 12 bytes: https://codegolf.stackexchange.com/a/132396/59530

Kotlin, 50 bytes
{i:Int->i.toString(2).run{count{it>'0'}>length/2}}

Lambda of implicit type (Int) -> Boolean. Version 1.1 and higher only due to usage of Int.toString(radix: Int).
Unfortunately TIO's Kotlin runtime seems to be 1.0.x, so here's a sad dog instead of a TIO link:

https://pl.kotl.in/Ipf0tvo_p saves 7 bytes

C (gcc), 51 48 41 40 bytes
i;f(n){for(i=0;n;n/=2)i+=n%2*2-1;n=i>0;}

Try it online!

Based on OP's clarification, you can remove unsigned

Since nnn is positive, you can change n>>=1 to n/=2. I also think you can use ~n instead of n^-1, which should also allow you to change && to &

Weird things happen when I edit comments - "nnn" means n, and never mind about changing && to &, I don't think that would work. But changing it to * seems to work

@musicman523 The && was only to handle the unsigned case but since I only need to handle positive integers I can remove it all together.  Good pouint about /= being shorter that >>= though, Thanks !

You can save one byte changing n&1?++i:--1 to i+=n%2*2-1. You might also be able to get rid of >0 by stating that you will output zero for heavy and nonzero for not heavy

@musicman523 That's a nice trick to save another byte.  I think true and false are already well defined in C so I won't push that issue.

Ignore what I said before - since i could be negative, you do indeed need >0

Regex (ECMAScript), 85 73 71 bytes
^((?=(x*?)\2(\2{4})+$|(x*?)(\4\4xx)*$)(\2\4|(x*)\5\7\7(?=\4\7$\2)\B))*$

Try it online!
explanation by Deadcode
The earlier 73 byte version is explained below.
^((?=(x*?)\2(\2{4})+$)\2|(?=(x*?)(\4\4xx)*$)(\4|\5(x*)\7\7(?=\4\7$)\B))+$
Because of the limitations of ECMAScript regex, an effective tactic is often to transform the number one step at a time while keeping the required property invariant at every step. For example, to test for a perfect square or a power of 2, reduce the number in size while keeping it a square or power of 2 (respectively) at every step.
Here is what this solution does at every step:
If the rightmost bit is not a 1, the rightmost 1 bit (if it is not the only 1 bit, i.e. if the current number is not a power of 2) is moved one step to the right, effectively changing a 10 to a 01 (for example, 11011000 → 11010100 → 11010010 → 11010001), which has no effect on the number's binary-heaviness. Otherwise, the rightmost 01 is deleted (for example 10111001 → 101110, or 1100111 → 11011). This also has no effect on the number's heaviness, because the truth or falsehood of \$ones>zeroes\$ will not change if \$1\$ is subtracted from both; that is to say,
\$ones>zeroes⇔ones-1>zeroes-1\$
When these repeated steps can go no further, the end result will either be a contiguous string of 1 bits, which is heavy, and indicates that the original number was also heavy, or a power of 2, indicating that the original number was not heavy.
And of course, although these steps are described above in terms of typographic manipulations on the binary representation of the number, they're actually implemented as unary arithmetic.
# For these comments, N = the number to the right of the "cursor", a.k.a. "tail",
# and "rightmost" refers to the big-endian binary representation of N.
^
(                          # if N is even and not a power of 2:
    (?=(x*?)\2(\2{4})+$)   # \2 = smallest divisor of N/2 such that the quotient is
                           # odd and greater than 1; as such, it is guaranteed to be
                           # the largest power of 2 that divides N/2, iff N is not
                           # itself a power of 2 (using "+" instead of "*" is what
                           # prevents a match if N is a power of 2).
    \2                     # N = N - \2. This changes the rightmost "10" to a "01".
|                          # else (N is odd or a power of 2)
    (?=(x*?)(\4\4xx)*$)    # \4+1 = smallest divisor of N+1 such that the quotient is
                           # odd; as such, \4+1 is guaranteed to be the largest power
                           # of 2 that divides N+1. So, iff N is even, \4 will be 0.
                           # Another way of saying this: \4 = the string of
                           # contiguous 1 bits from the rightmost part of N.
                           # \5 = (\4+1) * 2 iff N+1 is not a power of 2, else
                           # \5 = unset (NPCG) (iff N+1 is a power of 2), but since
                           #   N==\4 iff this is the case, the loop will exit
                           #   immediately anyway, so an unset \5 will never be used.
    (
        \4                 # N = N - \4. If N==\4 before this, it was all 1 bits and
                           # therefore heavy, so the loop will exit and match. This
                           # would work as "\4$", and leaving out the "$" is a golf
                           # optimization. It still works without the "$" because if
                           # N is no longer heavy after having \4 subtracted from it,
                           # this will eventually result in a non-match which will
                           # then backtrack to a point where N was still heavy, at
                           # which point the following alternative will be tried.
    |
        # N = (N + \4 - 2) / 4. This removes the rightmost "01". As such, it removes
        # an equal number of 0 bits and 1 bits (one of each) and the heaviness of N
        # is invariant before and after. This fails to match if N is a power of 2,
        # and in fact causes the loop to reach a dead end in that case.
        \5                 # N = N - (\4+1)*2
        (x*)\7\7(?=\4\7$)  # N = (N - \4) / 4 + \4
        \B                 # Assert N > 0 (this would be the same as asserting N > 2
                           # before the above N = (N + \4 - 2) / 4 operation).
    )
)+
$       # This can only be a match if the loop was exited due to N==\4.

While this is inspired by Deadcode's answer, the algorithm is different enough that I felt it deserved a separate answer rather than a comment.

This is phenomenal, and exactly what I wanted to see (somebody blowing my regex out of the water with a much more concise algorithm). But your comments really don't explain it at all, and the commented 73-byte version of the regex does not even work (the backrefs \5 onward are off by one). I have studied this and explained and commented it in my answer (because StackExchange doesn't allow multiline replies).

Retina, 37 34 bytes
.+
$*
+`(1+)\1
$1@
@1
1
+`.\b.

1+

Try it online! Link includes smaller test cases (the larger ones would probably run out of memory). Edit: Saved 3 bytes thanks to @MartinEnder. Explanation: The first stage converts from decimal to unary, and the next two stages convert from unary to binary (this is almost straight out of the unary arithmetic page on the Retina wiki, except that I'm using @ instead of 0). The third stage looks for pairs of dissimilar characters, which could be either @1 or 1@, and deletes them until none remain. The last stage then checks for remaining 1s.

${1} can be $+. Or you could use ! instead of 0 and then shorten 01|10 to .\b..

@MartinEnder Huh, does $+ do the right thing when the pattern contains a |? I wonder whether I could have used that before...

no, $+ is super stupid and simply uses the group with the biggest number, whether it was used or not. It's only useful for golfing when you've got more than nine groups or in a situation like the one here, and I don't know why I'd ever use it in a production regex.

R, 43 bytes
max(which(B<-intToBits(scan())>0))/2<sum(B)

Try it online!
             intToBits(scan())              # converts to bits
          B<-                 >0            # make logical and assign to B
max(which(                      ))/2        # get the length of the trimmed binary and halve
                                    <sum(B) # test against the sum of bits

+1 neat solution! I didn't even know about intToBits

Golfed off another 4 bytes: https://codegolf.stackexchange.com/a/132396/59530

Perl 6,  32  30 bytes
{[>] .base(2).comb.Bag{qw<1 0>}}

Test it
{[>] .polymod(2 xx*).Bag{1,0}}

Test it
Expanded:
{      # bare block lambda with implicit parameter ｢$_｣

  [>]  # reduce the following with &infix:« > »

    .polymod(2 xx *) # turn into base 2 (reversed) (implicit method call on ｢$_｣)
    .Bag\            # put into a weighted Set
    { 1, 0 }         # key into that with 1 and 0
                     # (returns 2 element list that [>] will reduce)
}

Haskell, 41 34
g 0=0
g n=g(div n 2)+(-1)^n
(<0).g

If n is odd, take a -1 if it's even, take a 1. Add a recursive call with n/2 and stop if n = 0. If the result is less than 0 the number is binary-heavy.
Try it online!
Edit: @Ørjan Johansen found some shortcuts and saved 7 bytes. Thanks!

mod n 2 can be just n, and it's a byte shorter without an accumulator. Try it online!

Wise, 40 39 bytes
::^?[:::^~-&[-~!-~-~?]!~-?|>]|:[>-?>?]|

Try it online!
Explanation
::^?                                      Put a zero on the bottom
    [                                     While
     :::^~-&                              Get the last bit
            [-~!-~-~?]!~-?|               Increment counter if 0 decrement if 1
                           >              Remove the last bit
                            ]|            End while
                              :[>-?>?]|   Get the sign

Julia, 22 bytes
x->2*x<4^count_ones(x)

-1 byte using a numeric literal coefficient

R, 39 37 bytes
sum(intToBits(x<-scan())>0)>2+log2(x)

This is a combination of the methods used by @MickyT and @Giuseppe, saving another few bytes.
sum(intToBits(x) > 0) counts the amount of 1 bits, and 2+log2(x)/2 is half of the total amount of bits, when rounded down. We don't have to round down because of the behaviour when the two values are equal.

Pyth, 9 7 bytes
ehc2S.B

Try it here.
-2 thanks to FryAmTheEggman.

Another 9 byte approach: >ysJjQ2lJ

7 bytes but I feel like there should still be something shorter...

@FryAmTheEggman Hmm...that could only work as a full program. (I knew there was a way to use .B!)

C# (.NET Core), 62, 49 bytes
Without LINQ.
EDIT:  dana with a -13 byte golf changing the while to a recursive for and returning a bool instead of integer.
x=>{int j=0;for(;x>0;x/=2)j+=x%2*2-1;return j>0;}

Try it online!

Jelly, 6 bytes
Bµċ0<S

Try it online!

Bo-S can be used to calculate the binary "weight" of the input, unfortunately the shortest way to use that appears to be Bo-S>0...

@ETHproductions Yep, there's no "is positive" atom yet.

Well apparently Ḷ works :P

Rust, 30 bytes
|x:u64|x<1<<2*x.count_ones()-1

Try it online!

J, 12 bytes
(+/>-:@#)@#:

J executes verbs right-to-left, so let's start at the end and work our way towards the beginning.
Explanation
         #:       NB. Convert input to list of bits
       -:@#       NB. Half (-:) the (@) length (#)
          >       NB. Greater than
         +/       NB. Sum (really plus (+) reduce (/)

(#<2*+/)@#: should save 1 unless I’m missing something.

05AB1E, 4 bytes
Returns 1 if binary heavy, 0 otherwise
b.MW

Try it online!
b            Convert to binary
 .M          Push a list of most frequent chars (contains 0 and 1 in case of a tie)
   W         Push the lowest value from the list
             Implicit output

Vyxal, 4 bytes
bĊ↑h

Try it Online!
Explained
bĊ↑h
b    # binary
 Ċ↑h # most values outputted, if tie then 0

3 bytes by porting Factor - Try it Online!

Japt, 9 bytes
0<¢¬x®r0J

Try it online!
Explanation:
0<¢¬x®r0J
  ¢        // Binary; Base-2 of the input
   ¬       // Split into an array
     ®     // Map; At each item:
      r0J  //   Replace 0 with -1
    x      // Sum;
0<         // If the result is greater-than 0, return true; Else, false;

Common Lisp, 49 48 bytes
(lambda(x)(>(logcount x)(/(integer-length x)2)))

Try it online!
-1 byte thanks to ceilingcat!
Only two builtin functions (and two operators), but with the long names typical of Common Lisp! At least conceptually very simple.

Excel, 88 bytes
Un-golfed answer that only handles values up to 511.
=SUMPRODUCT(--MID(DEC2BIN(A1),ROW(OFFSET(A$1,,,LEN(DEC2BIN(A1)))),1))>LEN(DEC2BIN(A1))/2

Excel & CSV, 75 bytes.
Save as CSV, and insert Input before first comma:
,=DEC2BIN(A1),=SUMPRODUCT(--MID(B1,ROW(OFFSET(A$1,,,LEN(B1))),1))>LEN(B1)/2

R, 74 62 bytes
x=scan();n=strtoi(intToBits(x)[0:log2(x)+1]);2*sum(n)>sum(n|T)

Edit:
Thanks Giuseppe! -12 bytes
Try it online!

Let's see...you can use strtoi instead of as.logical and instead of length(n) you can use sum(n|T) and then obviously you want 2*sum(n)>length(n), aaand you can use x=scan() instead of a function definition (I did the same!); those are just handy R golfing tips :)

@Giuseppe Very neat shortcut with sum(n|T). Thanks!

Ruby, 39 32 bytes
->n{b=n.digits 2;b.sum>b.size/2}

Attempt This Online!

You only need check that the 1-count is more than half, so ->n{b=n.to_s 2;b.count(?1)>b.size/2} is 3 bytes shorter.

PowerShell, 72 bytes
([convert]::ToString("$args",2)-replace'1','+1'-replace'0','-1'|iex)-gt0

Try it online!
Converts to Base 2, changes 100 to +1-1-1 and eval, checks if the result ends up >0.

TIS-100, 432 Bytes
105502 Cycles, 6 Nodes, 46 Instructions
@1
MOV RIGHT NIL
MOV UP DOWN
@2
MOV DOWN LEFT
@5
S:MOV ANY ACC
L:SUB 2
SWP
ADD 1
SWP
JGZ L
JLZ B
MOV 0 DOWN
A:MOV 0 ACC
SWP
SUB DOWN
MOV ACC RIGHT
JMP S
B:MOV 1 DOWN
JMP A
@6
MOV 0 UP
L:MOV LEFT ACC
SUB 1
JEZ B
ADD 1
MOV ACC LEFT
MOV 0 DOWN
JMP L
B:MOV 0 UP
MOV 1 DOWN
JMP L
@9
S:MOV UP ACC
MOV ACC UP
JEZ B
MOV 1 RIGHT
JMP S
B:MOV -1 RIGHT
@10
L:SWP
ADD LEFT
SWP
MOV UP ACC
JEZ L
SWP
JGZ B
MOV 0 DOWN
JMP K
B:MOV 1 DOWN
K:MOV 0 ACC

EDIT: Explained:
@5 receives any value and divides by two. It passes the remainder down and the quotient right, making sure to correct any errors by subtracting the remainder from @9. @6 receives quotients from @5. If the quotient is 1, it terminates the loop by passing a signal down to print out the answer, then passing a signal to @1 via @2 to read in the next value. Speaking of, @9 and @10 hold the greater than/less than state of 1s and 0s by adding 1 for each 1 and -1 for each 0, then jumping based on the sum.
Play the level by pasting this into the game.
function get_name()
    return "BINARY COLLAPSER"
end
function get_description()
    return { "WRITE 1 TO OUT IF THE BINARY REPRESENTATION OF IN CONTAINS MORE ONES THAN ZEROES", "WRITE 0 TO OUT OTHERWISE", "IGNORE LEADING ZEROES"}
end
function get_streams()
    input = {}
    output = {}
    for i = 1,39 do
      x = math.random(1, 999)
        input[i] = x
        ones = 0
        zeroes = 0
        while (x>0) do
            if (x%2 == 1) then
                ones = ones + 1
                x = x - 1
            else
                zeroes = zeroes + 1
            end
            x = x/2
        end
        if (ones > zeroes) then
            output[i] = 1
        else
            output[i] = 0
        end
    end
    return {
        { STREAM_INPUT, "IN.A", 1, input },
        { STREAM_OUTPUT, "OUT.A", 2, output },
    }
end
function get_layout()
    return {
        TILE_COMPUTE,   TILE_COMPUTE, TILE_COMPUTE,     TILE_COMPUTE,
        TILE_COMPUTE,   TILE_COMPUTE,   TILE_COMPUTE,   TILE_COMPUTE,
        TILE_COMPUTE,   TILE_COMPUTE,   TILE_COMPUTE,   TILE_COMPUTE,
    }
end

You can now try it online! (Though, it seems this solution gets stuck when 1 is given as input.)

Java (OpenJDK 8), 43 bytes
n->n.bitCount(n)>n.toString(n,2).length()/2

Try it online!
Java (OpenJDK 8), 31 bytes using BigInteger
I suspect this would need to count the import for 28 more bytes though.
n->n.bitCount()>n.bitLength()/2

Try it online!

Didn't even knew about bitCount. Nice answer! I had something like this in my mind: n->{String s=n.toString(n,2);return s.replace("0","").length()>s.length()/2;}

@KevinCruijssen If you want to try another Java solution, I'd suggest a loop with n/=2 and n%2>0?i++:i--. Might be shorter; at least close.

It would be simple to use numberOfLeadingZeros to get the length, but the method name is 20 letters long :(

If you use Java 9's JShell you don't need the import since java.math.* is imported implicitly.

@DavidConrad Thanks, it seems to have a usefult list of default imports for golfing

q/kdb+, 34 33 28 bytes
Solution:
sum[b]>.5*(#)*:[b&:]_b:2 vs

Examples:
q)sum[b]>.5*(#)*:[b&:]_b:2 vs 1
1b
q)sum[b]>.5*(#)*:[b&:]_b:2 vs 2
0b
q)sum[b]>.5*(#)*:[b&:]_b:2 vs 4
0b
q)sum[b]>.5*(#)*:[b&:]_b:2 vs 5
1b
q)sum[b]>.5*(#)*:[b&:]_b:2 vs 60
1b
q)sum[b]>.5*(#)*:[b&:]_b:2 vs 316
1b
q)sum[b]>.5*(#)*:[b&:]_b:2 vs 632
0b
q)sum[b]>.5*(#)*:[b&:]_b:2 vs 2147483647
1b
q)sum[b]>.5*(#)*:[b&:]_b:2 vs 2147483648
0b

Explanation:
Convert input to binary, chop off leading zeroes, compare whether there are more ones (sum[b]) than half the length of the list (0.5 * count...).
sum[b] > 0.5 * count first[where b] _ b:2 vs / ungolfed solution
                                        2 vs / convert right to base 2
                                      b:     / save in variable b for use later
                           where b           / indexes where b is true
                     first[       ]          / perform first on the stuff in brackets
                                    _        / drop, drops left items from right, basically drop all leading 0s
               count                         / returns length of this list
         0.5 *                               / half this value
       >                                     / greater-than, returns true or false
sum[b]                                       / how many 1s there are in b

Notes:
Golfing was simply replacing the q keywords with their k equivalents

PHP, 44 bytes
for(;$a=&$argn;$a>>=1)$r+=$a&1?:-1;echo$r>0;

Try it online!
PHP, 48 bytes
<?=($c=count_chars(decbin($argn)))[49]-$c[48]>0;

Try it online!

Octave, 26 bytes
@(a)sum(2*dec2bin(a)-97)>0

Try it online!

You can do something with mode(dec2bin(a)-48)

Python 2, 44 bytes
f=lambda n,c=0:f(n/2,c+n%2*2-1)if n else c>0

Try it online!
Old Answer, 47 bytes
c,n=0,input()
while n:c+=n%2*2-1;n/=2
print c>0

This is simply a port of @cleblanc's C answer. It's longer than other Python answers but I figured it was worth posting since it's a completely different method of finding the answer.
Try it online!

C#, 82 bytes
n=>{var s=System.Convert.ToString(n,2);return s.Replace("0","").Length>s.Length/2}

You can trim some more by treating the string as an IEnumerable.  n=>{var s=Convert.ToString(n,2);return s.Count(c=>c=='1')>s.Length/2;}

@GalacticCowboy That adds 11 bytes because you have to fully qualify Convert and include using System.Linq; (written shorter as namespace System.Linq{}). Nice idea just doesn't shave off enough to warrant the saving in this case.

k, 22 bytes
{.5<avg X@&:|\X:0b\:x}

q translation:
{.5 < avg X where maxs X:0b vs x}

Interpreter available here

11 bytes in q: .5<avg 2 vs

Python, 33 bytes
lambda x:2*x<4**bin(x).count('1')

Try it online!

tinylisp, 93 bytes
(d _(q((N R D)(i(l N 2)(i R(_ R 0(a(s(s 1 N)N)D))(l D 1))(_(s N 2)(a R 1)D
(d H(q((N)(_ N 0 0

This was fun. I went through a few different ideas before I was able to beat my initial 105-byte solution that used library functions.
Try it online!
Ungolfed + explanation
(load library)

(def _binary-heavy
 (lambda (num rest diff)
  (if (less? num 2)
   (if rest
    (_binary-heavy rest 0 (+ diff (if num (neg 1) 1)))
    (less? diff 1))
   (_binary-heavy (- num 2) (inc rest) diff))))

(def binary-heavy (lambda (num) (_binary-heavy num 0 0)))

There are no division or modulo builtins in tinylisp, so we use an algorithm that only does addition and subtraction.
The helper function _binary-heavy has three arguments:

num starts out as the integer we're analyzing
rest ends up as half of num, and then becomes the new num in a recursive call
diff stores the difference between the number of 0 bits and the number of 1 bits we've seen so far

The function recurses in a couple of different ways:

If num is 2 or greater, subtract 2 from num, add 1 to rest, and recurse.
If num is 0 or 1, then rest now contains the original num divided by 2, and num contains the original num mod 2. In other words, num is the least significant bit, and rest is the rest of the number. Here we have two possibilities:

If rest is not zero, there are more bits to process, so we update diff and recurse with rest as the new num. Since diff is (number of 0 bits) minus (number of 1 bits), we want to add 1 if num is 0 and -1 if num is 1. The golfed code accomplishes this by adding (s(s 1 N)N)--in infix, 1 - 2*num.
If rest is zero, we're done and just need to return a result. Note that num now holds the most significant bit, which is always 1. So the final diff is diff - 1, and we want to check whether this is less than 0. But diff - 1 < 0 is the same as diff < 1, which is what we return.

Finally, we define our main function, binary-heavy, to take one argument num and pass it on to the helper function, with rest and diff initially 0.

Ruby, 30 27 bytes
->n{n<4**n.digits(2).sum/2}

Try it online!

Alchemist, 122 bytes
_->In_a
n+a+0z->n+z
a+z->b
n+0a->d
0n+z->2c
0n+0z+b->a
0n+0z+0b+a->a+n
c+d->
0z+0a+0b+0_+0f->s+f
0c+s->Out_c
0d+c+s->Out_f

Try it online!
Test cases
Outputs 0 for false and 1 for true.

APL (Dyalog Unicode), 14 bytes
-6 thanks to @Razetime
-1 thanks to @rak1507
f←(≢<2×+/)2∘⊥⍣¯1

explanation:
(≢<2×+/)2∘⊥⍣¯1
        2∘⊥⍣¯1     ⍝ convert the number to a binary vector inverting decode (⊥)
   2×+/            ⍝ doubled count of ones in the binary representation
 ≢                 ⍝ amount of bits in the binary representation
  <                ⍝ is it smaller?

Try it online!
original solution:
(+/∘~<+/)2∘⊥⍣¯1

explanation:
(+/∘~<+/)2∘⊥⍣¯1
         2∘⊥⍣¯1     ⍝ convert the number to a binary vector inverting decode (⊥)
      +/            ⍝ count of ones in the binary representation
    ~               ⍝ negate the number
 +/∘                ⍝ count ones in the negated number, effectively counting zeros
     <              ⍝ is the amount of zeros smaller than the amount of ones?

-6

Factor, 35 13 bytes
[ >bin mode ]

Try it online!
Outputs 49 for truthy and 48 for falsey.

>bin Convert input integer to binary string
mode Return the character that occurs most often (ties return 48)

Arturo, 36 bytes
$=>[<size d--1∑d:<=digits.base:2&]

Try it

Uiua, 12 11 8 bytes
<×2⊃/+⧻⋯

Try it!
<×2⊃/+⧻⋯
       ⋯  # convert number to bit array
      ⧻   # length
    /+    # sum
   ⊃      # fork (do sum and length on the same value)
 ×2       # double
<         # less than

Stacked, 17 bytes
[bits tmo sum 0>]

Try it online!
This is a pretty simple answer. Takes the bits of the top number, perofrms 2n-1 (tmo), calculates their sum, and checks if it is > than 0.

TI-Basic, 29 bytes
:Prompt N
:While int(N
:.5int(N→N
:P-1+4fPart(N→P
:End
:P>0

CJam, 10 bytes
qi2b$_:!$>

Try it online
qi2b   e# convert input to base 2 as an array (43 => [1,0,1,0,1,1,])
$      e# sort array ([0,0,1,1,1,1])
_:!    e# make copy of array and invert truth value of each element ([1,1,0,0,0,0])
$      e# sort copy ([0,0,0,0,1,1])
>      e# if first array is lexicographically greater than copy, return true (only happens if 1st array had more ones than zeroes).

05AB1E, 8 6 bytes
-2 bytes thanks to Erik the Outgolfer
b1Ý¢`‹

Try it online! or Try all tests

b{γ€g¥ is what I've tied you with ;).

Pari/GP, 27 bytes
n->2*vecsum(b=binary(n))>#b

Try it online!

GolfScript, 15 bytes
~2base.0-,\1-,>

Try it online!

Sed, 218 bytes (91 with unary input)
:u
s/\b9/;8/
s/\b8/;7/
s/\b7/;6/
s/\b6/;5/
s/\b5/;4/
s/\b4/;3/
s/\b3/;2/
s/\b2/;1/
s/\b1/;0/
s/\b0//
/[^;]/s/;/&&&&&&&&&&/g
tu
s/$/x/
:a
s/;;/,/g
s/,x/,x0/
s/;x/x1/
y/,/;/
s/10//
s/01//
ta
s/x$/0/
s/\(.\)\1/\1/g
s/x//

Outputs 1 for truthy and 0 for falsey.
Decimal to unary conversion from this answer.

You can use the -r flag in GNU sed to avoid escaping parentheses. Also you can use unnamed labels (empty label) instead of the u label to save two further bytes. Also, s/10//;s/01// can become s/10|01//.

05AB1E, 6 bytes
b{γ€g¥

Try it online!
Results:

0 or higher means a non-heavy number.
Negative numbers represent the binary-heavy numbers.

Pyt, 4 bytes
←ɓąṀ

Explanation:
←             Get input
 ɓ            Get binary representation as string
  ą           Convert to array of digits
   Ṁ          Get the mode of the array (this returns the smallest if there are multiple)

Attache, 13 bytes
{1~_>0~_}@Bin

Try it online!
Explanation
{1~_>0~_}@Bin
          Bin    convert the input to binary
{       }@       _ = binary input
 1~_             count of 1s in input
    >            is greater than?
     0~_         the count of 0s in the input

Alternatives
17 bytes: Min@Commonest@Bin
17 bytes: /N@@Commonest@Bin
18 bytes: {Sum@_/#_>0.5}@Bin
18 bytes: /Id@@Commonest@Bin
18 bytes: Last@Commonest@Bin
19 bytes: {_>0.5}@Average@Bin
22 bytes: 0&`<@Sum##{2*_-1}=>Bin
23 bytes: `<@@{Sum@`=&_=>0'1}@Bin
23 bytes: {&`<!Sum@`=&_=>0'1}@Bin
30 bytes: {&`<!Sum=>Table[`=,0'1,_]}@Bin

Red, 74 bytes
func[n][(sum b: collect[until[keep n % 2 1 > n: n / 2]])>((length? b)/ 2)]

Try it online!

Forth (gforth), 56 bytes
: f 0 swap begin 2 /mod >r 2* 1- + r> ?dup 0= until 0> ;

Try it online!
Explanation
Loop through the binary digits of the number and add 1 to a counter if the digit is 1, and subtract 1 if the digit is 0. If the total is greater than 0 there are more 1's than 0's.
Code Explanation
: f            \ start new word definition
  0 swap       \ add a counter and move it below the input number on the stack
  begin        \ start an uncounted loop
    2 /mod     \ get the quotient and remainder of dividing by 2 (get binary digit and rest of number)
    >r         \ stick the remaining number on the return stack
    2* 1- +    \ convert remainder to 1 or -1 and add to counter
    r>         \ remove remaining number from the return stack
    ?dup       \ duplicate if not equal to 0
  0= until     \ end the loop if the remaining number is 0
  0>           \ return true if counter is greater than 0
;              end word definition

C, 49 bytes
f(n){int a=0;for(;n;n/=2)a+=n%2?1:-1;return a>0;}

Possible too much long for you...

Could you specify the compiler you used?

Possibly f(n,a){for(a=0;n;n/=2)a+=n%2*2-1;a=a>0;}?

@JonathanFrech each C compiler

I would think there are a lot of C compilers out there. Do you mean C89 compliant or something along those lines?

Yes C89 standard (I hope at last)... It would be good for me to know some C compiler not compile above code

Would it not be C89 compliant if one threw an error upon encountering a declaration-less variable declaration, e.g. f(n)?

For me show some warning but compile

Stax, 4 bytes
:B:M

Run and debug it
:B gets the binary digits of the input.  :M gets the mode.  In the case of a tie, it will be the last element to appear (always 0).

K (ngn/k), 17 13 10 bytes
-4 bytes by changing approach
-3 bytes by making code tacit (thanks @ngn)
0>+/1-2*2\

Try it online!

2\x convert input to base-2; this already trims any leading 0's
1-2* convert 1's to -1's and 0's to 1's
0>+/ is the sum less than 0?

{ x} can be removed

D'oh, good catch!

ARM Thumb-2 (alternative), 16 bytes
Alternative approach which mirrors this x86 answer although it is just as small to maintain the bool return value.
Since we need to mov the result to r0 anyways, we can invert the operation and use that opcode to return the sign bit.
Raw machine code:
2100 0840 bf2c 3901 3101 d1fa 0fc8 4770

Uncommented Assembly:
        .syntax unified
        .arch armv6t2
        .globl binary_heavy
        .thumb
        .thumb_func
binary_heavy:
        movs    r1, #0
.Lloop:
        lsrs    r0, r0, #1
        ite     cs
        subcs   r1, #1
        addcc   r1, #1
        bne     .Lloop
.Lloop_end:
        lsrs    r0, r1, #31
        bx      lr

The explanation is the same as the original one, but instead of adding to two different variables, we are adding and subtracting from the same variable, and returning the sign bit by doing a logical right shift by 31.
ARM Thumb-2 (previous approach), 22 20 bytes
Longer but uses an original idea.
Raw machine code:
2101 2200 0840 bf2c 3201 3101 d1fa 428a
4140 4770

Uncommented Assembly:
        .syntax unified
        .arch armv6t2
        .globl binary_heavy
        .thumb
        .thumb_func
binary_heavy:
        movs    r1, #1
        movs    r2, #0
.Lloop:
        lsrs    r0, r0, #1
        ite     cs
        addcs   r2, #1
        addcc   r1, #1
        bne     .Lloop
.Lloop_end:
        cmp     r2, r1
        adcs    r0, r0
        bx      lr

Explanation

We are about to do some wonky stuff with the condition codes, so you might want to look at the condition code table in this article if you aren't familiar with them.

C signature:
bool binary_heavy(uint32_t val);

First, set up r1 to count the zeros and r2 to count the ones.
Wait, why do we start with zeros = 1? You'll see.
binary_heavy:
        movs    r1, #1
        movs    r2, #0

Then, begin our loop. All the logic can be handled by how lsrs updates the flags.
lsrs does a logical right shift, stores the last bit shifted in the carry flag, and sets the zero and negative flags based on the result.
So we can basically do this logic using nothing but lsrs and some flag checking:
do {
    if (val & 1) {
        ++ones;
    } else {
        ++zeros;
    }
} while (val >>= 1);

.Lloop:
        lsrs    r0, r0, #1

First, we do an IT block to add to either the ones count or the zeroes count.
        ite     cs
        addcs   r2, #1
        addcc   r1, #1

Thankfully, since most narrow instructions do not set flags in IT blocks, we can also use the same lsrs flags to check if the value is still non-zero and loop.
        bne     .Lloop

Here is why we set the zeros counter to 1.
We can do a shortcut if we can turn the condition into a greater than or equal. However, if the ones and zeros are equal, it is considered not binary heavy. That is why we need to start the zeros with 1, because we can offset it.
The shortcut? You guessed it, an add with carry!

We know that r0 is zero since if it wasn't, we'd be looping now.

That means that r0 will be 0 + 0 + carry.

Greater than or equal means the carry flag is set

Therefore, the carry flag being set means greater than or equal.

Since we modified the zeros initial value, greater than or equal means that the number is binary heavy.

Which means the carry flag is set if the number is binary heavy.

So we are essentially setting r0 to the carry flag, making it act as a boolean....and our return value.
.Lloop_end:
        cmp     r2, r1
        adcs    r0, r0

Return.
        bx    lr

J-uby, 49 32 bytes
Based on G B’s Ruby answer.
:<%(~:digits&2|:sum|:**&4|~:/&2)

Attempt This Online!

Husk, 4 bytes
>.Aḋ

Try it online!
>.Aḋ
  A   # The average
   ḋ  # of the binary digits
>     # is greater than
 .    # 0.5

K (ngn/k), 19 bytes
{n:2\x;(#n^1)<#n^0}

Try it online!
This is the first time where using a variable saves more bytes than just duplicate. It's also much simpler than I thought. Return 1 for true, and 0 for false.
Explanation:
{n:2\x;(#n^1)<#n^0}    Main function. Takes x as input
 n:                    Assign variable n to
   2\x;                x converted to base 2, return back a binary array
       (#   )          Length of
         n^1           n without 1 in its array
             <         Less than
              #        Length of
               n^0     n without 0 in its array

///, 156 bytes
/9/8*//8/7*//7/6*//6/5*//5/4*//4/3*//3/2*//2/1*//1/0*//*0/9*//0///*/>oi//i>/i//io/oi//oii/i\o//oi/_i//_///>o/>//>///i\o///o\i///|i/T//Ti/T//|o/F//Fo/F//|/F/

Try it online!
The input is |n where n is a number.
Explanation:
/9/8*//8/7*//7/6*//6/5*//5/4*//4/3*//3/2*//2/1*//1/0*//*0/9*//0//

Convert from Base 10 (decimal) to unary (Taken from the wiki)
/*/>oi//i>/i//io/oi//oii/i\o//oi/_i//_///>o/>//>//

Convert from unary to binary (i and o) (Also, taken from the wiki)
/i\o///o\i//

Replace io to empty string as many times, then repeat but oi to empty string
/|i/T//Ti/T/

If the new string has i, Replace to T
/|o/F//Fo/F/

Else, if the new string has o, Replace to F
/|/F/

Else replace to F
And output the new string.

Jelly, 4 bytes
BÆṃP

Try it online!
Nothing clever here :P
   P    Take the product of
 Æṃ     the most common
B       binary digits.

Thunno, \$8\log_{256}(96)\approx\$ 6.58 bytes
bD1cs0c>

Attempt This Online!
Explanation
   # Implicit input
bD # Binary, duplicate
1c # Count of 1s
s  # Swap
0c # Count of 0s
>  # Greater than?
   # Implicit output

JavaScript (Node.js), 44 47 bytes

-3 bytes thanks to l4m2 tip and some other improvements

Different approach but can't beat the recursive JS answers.
l=>[...l.toString(a=2)].map(e=>a+=e-.5)&&a>2

Try it online!
The algorithm is pretty straightforward.
We convert the decimal into binary, and then we parse each bit while maintaining a score. For each 1 we increase the score by 0.5, and for each 0 we decrease it by 0.5.
At the end we check if the score is greater than 2 (because it was shorter that way for the declaration of variable a)

e*2-1 => e-.5

@l4m2 Thanks for the tip! It's simple but for some reason i didn't think of it.
I updated my solution

Turing Machine Code, 332 bytes
Terminates in state halt for truthy, or halt-r for falsey.
0 * * r 0
0 _ _ l 1
1 0 9 l 1
1 9 8 l 2
1 8 7 l 2
1 7 6 l 2
1 6 5 l 2
1 5 4 l 2
1 4 3 l 2
1 3 2 l 2
1 2 1 l 2
1 1 0 l 2
1 _ _ l A
2 _ _ l 3
2 * * l 2
3 1 0 l 3
3 * 1 r 4
4 * * r 4
4 _ _ r 0
A * * l A
A 1 & l B
A 0 & l C
A & & l A
B 0 & r D
B * * l B
C 1 & r D
C * * l C
D * * r D
D _ _ l A
B _ _ * halt
C _ _ * halt-r
A _ _ * halt-r

Try it online: http://morphett.info/turing/turing.html?ad9fead44f5ee4db3ee96c4b6c9d3f0b

Go, 101 bytes
import(."strconv";."strings")
func f(n int64)bool{x:=FormatInt(n,2)
return Count(x,"1")>Count(x,"0")}

Attempt This Online!
Commented
import (."strconv"; ."strings")        // Boilerplate
func f(n int64) bool {                 // Boilerplate
x := FormatInt(n, 2)                   // Convert n to binary
return Count(x, "1") > Count(x, "0")}  // Is the count of 1s more than the count of 0s?

Thunno 2, 6 bytes
ḃk#cẸ<

Attempt This Online!
Explanation
ḃk#cẸ<  # Implicit input           -> n
ḃ       # Binary representation    -> binary
 k#     # Push the pair [0, 1]     -> binary, [0, 1]
   c    # Counts of each           -> [count of 0, count of 1]
    Ẹ   # Dump onto stack          -> count of 0, count of 1
     <  # Less than                -> count of 0 < count of 1
        # Implicit output

Uiua, 7 bytes
>∩/+¬.⋯

Try it!
      ⋯     # encode as bits
    ¬.      # make a copy with bitwise-NOT
 ∩          # for each of these:
  /+        #   sum
>           # is the second bigger than the first?

Fortran (GFortran), 38 bytes body, 13 bytes boilerplate
program x

read*,n;print*,2*popcnt(n)>64-leadz(n)

end

Try it online:
1,
2,
4,
5,
60,
316,
632,
2147483647,
2147483648
The code reads a single 64 bit integer n from standard input and ouputs T for a binary-heavy number or F otherwise.
It uses popcnt() to count the number of ones and leadz() to count the number of leading zeros, both in the binary representation of n. The inequality to check is
popcnt(n) > (64 - leadz(n) - popcnt(n))

which can be written shorter as
(2 * popcnt(n)) > (64 - leadz(n))

The code needs to be compiled with -fdefault-integer-8 to enable 64 bit integers as the default.

CJam, 11 bytes
2,ri2bfe=:<

Try it online!

@MartinEnder How does :< work in your example? If it's a quick fold or quick map, I don't really get it.

@geokavel I just noticed it doesn't work when the input contains only 0-bits or only 1-bits so nevermind.

@EriktheOutgolfer I suggested sorting, RLE, comparison, but that assumes that both zero and one are present in the number.

@MartinEnder Oh yeah RLE is a big no here. I think you suggested ri2b$e\0f=:<` which is longer anyways.

Pyth, 15 bytes
<.*uXsHG1.BQ,ZZ

Try it online! Probably not the shortest solution out there, but I find it elegant.
Explanation
         .BQ       # Convert input to a binary string
   u        ,ZZ    # Reduce starting with (0, 0)...
    XsHG1          # ...by adding 1 to the first element of the couple if a 0 is encountered, or to the second element if a 1 is encountered
 .*                # Splat the couple: (x, y) -> x y
<                  # Check that x < y (x being the number of zeros, y the number of ones)

Probably?

@EriktheOutgolfer At least mine has an explanation.

Check, 45 41 bytes
>\          #v
#:>2%R+r\)\$##?
d$R-)>]*!p

Try it online!
This is probably golfable. I don't like the huge space on the first line.
Explanation
The program starts out with the input number on top of the stack. The IP is in 1D mode.
The > pushes a 0 to the stack, and then the \ swaps it with the input number. The stack now looks like 0, input, and the register is initialized to 0.
#v turns the IP into 2D mode and makes it start moving downwards. The second line is a loop that does this:

If the current value is 0, end the loop.
Otherwise, take the current value modulo 2.
Add that value to the value of the register (which counts the number of ones), and then unconditionally add 1 to the other value on the stack (which counts the total number of digits).
Int-divide the current value by 2.

Once the loop exits, one value on the stack will contain the number of digits. Divide that by 2. Then, take the value in the register, which counts the total number of ones. If the number of ones is greater than the total number of digits // 2, then the condition is true. However, Check has no built-in for checking whether one number is greater than another, so this is the simplest way:

Subtract the two values. The condition is now only true when the result is negative.
Increment the value. The condition is now only true when the result is negative or 0.
Repeat a singleton array that many times. In Check, trying to repeat an array a negative amount of times yields an empty array, which means that the result will be an empty array if and only if the condition is true.
The !p negates the empty array and prints the result.

Ohm, 7 bytes
bS╞╠l;h

Explanation
bS╞╠l;h  Main wire
b        binary representation
 S       sorted
  ╞      grouped
   ╠l;   sorted by length
       h the first element

Swift 3, 101 bytes
func h(b:Int)->Any{let a=String(b,radix:2).characters;return a.reduce(0){$1=="1" ?$0+1:$0}>a.count/2}

Try it online

-11 bytes: func h(b:Int){let a=String(b,radix:2).characters;print(a.filter{$1=="1"}.count>a.count/2)}

-22 bytes with Swift 4 func h(b:Int){let a=String(b,radix:2);print(a.filter{$1=="1"}.count>a.count/2)}

Perl 5, 33 bytes
$_=sprintf"%b",<>;say y/1//>y/0//

Try it online!

Japt, 9 8 bytes
2Æ¤èXÃr<

Try it or run all test cases
2Æ¤èXÃr<     :Implicit input of integer U
2Æ           :Map each X in the range [0,2)
  ¤          :  Convert U to binary string
   èX        :  Count the occurrences of X
     Ã       :End map
      r<     :Reduce by less than

C (gcc), 37 bytes
i;f(n){for(;n;n/=2)i+=n%2*8-4;i=i>2;}

Idea is that we calculate difference of number of 1s and 0s multiplied by for, so we don't care that i might be 1 after previous invocation.
Try it online!

SNOBOL4 (CSNOBOL4), 144 bytes
 N =INPUT
A O =O REMDR(N,2)
 N =GT(N) N / 2 :S(A)
 K =SIZE(O) - 1
R O 0 ='' :S(R)
 L =SIZE(O)
 OUTPUT =GE(K - L,L) 0 :F(Y)S(END)
Y OUTPUT =1
END

Try it online!

Husk, 7 bytes
ΣFż*gOḋ

Try it online!
Explanation
ΣFż*gOḋ  -- implicit input N, for example: 5
      ḋ  -- convert N to base 2: [1,0,1]
     O   -- sort: [0,1,1]
    g    -- group equal elements: [[0],[1,1]]
 F       -- reduce by the following (ie. apply function to the two groups*):
  ż*     --   zip with multiplication, but keep trailing elements: [0*1,1] == [0,1]
Σ        -- sum: 1

* The special cases where N = 2x-1 (x = 0…) also works because a reduce (foldl1) with a singleton list simply returns that element.

Add++, 12 bytes
L,BBEDdb!Es<

Try it online!

bash 76
Pure bash!
i=$1;for((r=$[$1&1];i>>=1;)){ r=$[i&1]$r;};i=${#r};s=${r//1};((i>(${#s}*2)))

Demo:
isbinheavy() {
    i=$1;for((r=$[$1&1];i>>=1;)){ r=$[i&1]$r;};i=${#r};s=${r//1};((i>(${#s}*2)))
}

for val in 1 2 4 5 60 316 632 2147483647 2147483648 ;do
    if isbinheavy $val; then
        res=True
    else
        res=False
    fi
    printf "%-12s -> %32s -> %s\n" $val $r $res
done

Will render:
1            ->                                1 -> True
2            ->                               10 -> False
4            ->                              100 -> False
5            ->                              101 -> True
60           ->                           111100 -> True
316          ->                        100111100 -> True
632          ->                       1001111000 -> False
2147483647   ->  1111111111111111111111111111111 -> True
2147483648   -> 10000000000000000000000000000000 -> False

Explanation:

Set variable i to submited integer
Begin for loop by

setting variable r to low significant bit of $1
set end of loop on i variable, shifting them by 1 bit on each check

In loop:

add low significant bit of resulted $i on left side of $r

Then store into variable i, length of $r
Drop all 0 from string $r then store string into variable s.
numerically test if $i > 2 x length of $s

C# (.NET Core), 48 bytes
bool f(int x,int c=0)=>x<1?c>0:f(x/2,c-1+x%2*2);

Try it online!
There were already a few C# solutions, but this is the first recursive one.
An optional counter argument is use to count 0's and 1's. A 0 will decrement the counter and a 1 will increment it. We are done when no more 1's are present, a positive counter indicates there were a greater number of 1's than 0's.

MBASIC, 86 bytes
1 INPUT N
2 Q=INT(N/2):IF N MOD 2=1 THEN O=O+1 ELSE Z=Z+1
3 N=Q:IF N>0 THEN 2
4 PRINT O>Z

Prints -1 for true, 0 for false
Examples:
? 316
-1

? 632
 0

C# (.NET Core), 98 bytes
Way too long xD
y=>{var b=Convert.ToString(y,2);for(int i=y=0;i<b.Length;)y+=b[i++]=='1'?1:-1;return y>0?1>0:1<0;}

Try it online!

89 bytes

cQuents, 15 bytes
:uJ$);1)>uJ$);0

Note that it only works on the latest commit, had to fix a bug, so TIO may or may not work depending on when you read this.
Try it online!
Explanation
:uJ$);1)>uJ$);0

:                    Mode: sequence 1, given input n, output nth term in sequence
                     Each term in the sequence equals:
 u   ;1)             Count number of ones in
  J$)                                        binary representation of current index
        >            Greater than (returns 1 (truthy) if true and 0 (falsey) if false)
         u   ;0)     Count number of zeroes in           (implicit closing ')')
          J$)                                  binary representation of current index

CPU x86 instruction set, 18 bytes
00000750  8B4C2404          mov ecx,[esp+0x4]
00000754  31C0              xor eax,eax
00000756  D1E9              shr ecx,1
00000758  7302              jnc 0x75c
0000075A  40                inc eax
0000075B  40                inc eax
0000075C  48                dec eax
0000075D  85C9              test ecx,ecx
0000075F  75F5              jnz 0x756
00000761  C3                ret

it return >0 if the number is "binary-heavy" else if result is <=0 it is not
"binary-heavy". Code for test it and see how to call it:
; nasmw -fobj  this.asm
; bcc32 -v  this.obj

section _DATA use32 public class=DATA

global _main
global _BinHev
extern _printf
fmt db "%u -> %d" , 13, 10, 0, 0

section _TEXT use32 public class=CODE

      align   8
_BinHev:
      mov     ecx,  dword[esp+4]
      xor     eax,  eax
.0:   shr     ecx,  1
      jnc     .1
      inc     eax
      inc     eax
.1:   dec     eax
      test    ecx,  ecx
      jnz     .0
.z:   ret

_main:
      pushad
      mov     ebx,  1
      push    ebx
      call    _BinHev
      add     esp,  4
      push    eax
      push    ebx
      push    fmt
      call    _printf
      add     esp,  12
      mov     ebx,  2
      push    ebx
      call    _BinHev
      add     esp,  4
      push    eax
      push    ebx
      push    fmt
      call    _printf
      add     esp,  12
      mov     ebx,  4
      push    ebx
      call    _BinHev
      add     esp,  4
      push    eax
      push    ebx
      push    fmt
      call    _printf
      add     esp,  12
      mov     ebx,  5
      push    ebx
      call    _BinHev
      add     esp,  4
      push    eax
      push    ebx
      push    fmt
      call    _printf
      add     esp,  12
      mov     ebx,  60
      push    ebx
      call    _BinHev
      add     esp,  4
      push    eax
      push    ebx
      push    fmt
      call    _printf
      add     esp,  12
      mov     ebx,  316
      push    ebx
      call    _BinHev
      add     esp,  4
      push    eax
      push    ebx
      push    fmt
      call    _printf
      add     esp,  12
      mov     ebx,  632
      push    ebx
      call    _BinHev
      add     esp,  4
      push    eax
      push    ebx
      push    fmt
      call    _printf
      add     esp,  12
      mov     ebx,  2147483647
      push    ebx
      call    _BinHev
      add     esp,  4
      push    eax
      push    ebx
      push    fmt
      call    _printf
      add     esp,  12
      mov     ebx,  2147483648
      push    ebx
      call    _BinHev
      add     esp,  4
      push    eax
      push    ebx
      push    fmt
      call    _printf
      add     esp,  12

      popad
      mov     eax,  0
      ret

results:
1 -> 1
2 -> 0
4 -> -1
5 -> 1
60 -> 2
316 -> 1
632 -> 0
2147483647 -> 31
2147483648 -> -30

GNU AWK, 55 52 bytes
{for(b=0;$1;$1=rshift($1,1))$1%2?b++:b--;print(b>0)}

Step by step:
{
for(
    b=0;            # at the beginning of each loop, starts over the bit count
    $1;             # loops until input reaches zero
                    # (positive values return true evaluation)
    $1=rshift($1,1) # at the end of each loop, right shift bitwise the input by 1 bit
   )
      $1%2?b++:b--; # if input is even, +1 to the bit count; -1 if odd
print(b>0)          # after the looping, prints the evaluation of b>0; 1 if true, 0 if false
}

Try it online!

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


text:
Calculate the MU-numbers
The first two MU-numbers are 2 and 3.  Every other MU-number is the smallest number not yet appeared that can be expressed as the product of two earlier distinct MU-numbers in exactly one way.
Here are the first 10
2, 3, 6, 12, 18, 24, 48, 54, 96, 162

Task
Given a positive number calculate and output the nth MU-number.
This is a code-golf competition so you should aim to make your source code as small as possible.
OEIS A007335

0-indexing or 1-indexing?

@HyperNeutrino Either is fine.

Any idea why these are called MU-numbers? (Wild guess: Multiplication Unique?)

Pyth, 22 21 bytes
@u+Gfq2l@GcLTGheGQhB2

Try it online. Test suite.
0-indexed.
Explanation
@u+Gfq2l@GcLTGheGQhB2Q    Implicitly append Q and read+eval input to it.
                  hB2     Take the list [2, 2 + 1].
 u               Q        Put the list in G and apply this Q times:
               eG           Get last number in G.
              h             Add one.
    f                       Starting from that, find the first T such that:
          cLTG                Divide T by each of the numbers in G.
        @G                    Find the quotients that are also in G.
       l                      Get the number of such quotients.
     q2                       Check that it equals 2.
  +G                        Append that T to G.
@                    Q    Get the Q'th number in G.

The @ sign on the last line is misaligned. I can't make a suggested edit, since it's a 2-character change.

@user2357112 Fixed.

Haskell, 80 77 bytes
l#(a:b)|[x]<-[a|i<-l,j<-l,i<j,i*j==a]=a:(a:l)#b|1<2=l#b
((2:3:[2,3]#[4..])!!)

Try it online!
How it works
2:3:             -- start the list with 2 and 3 and append a call to # with
    [2,3]        -- the list so far and
         #[4..]  -- list of candidate elements

l # (a:b)        -- l -> list so far, a -> next candidate element, b -> rest c.el.
  | [x]<-[...]   -- if the list [...] is a singleton list
    =a:(a:l#b) -- the result is a followed by a recursive call with l extended
                    by a and b
  | 1<2=l#b      -- if it's not a singleton list, drop a and retry with b

                 -- the [...] list is
 [ i<-l,j<-l,    -- loop i through l and j through l and whenever
       i<j,      -- i<j and
       i*j==a]   -- i*j==a
  a|             -- add a to the list

R, 127 118 111 108 105 100 98 90 bytes
8 bytes thanks to Giuseppe.
r=3:2;for(i in 1:scan())r=c(min((g=(r%o%r)[i:-1<i])[colSums(g%o%g==g*g)+g%in%r<3]),r);r[3]

Try it online!

It took me forever to realize that < has lower precedence than + so I couldn't figure out what in the heck +g%in%r<3 was doing, and while I was doing that, you golfed down the two parts I was going to suggest... +1

@Giuseppe I just started to learn R today... nice to meet a decent R golfer.

I was going to say the same to you.............

Ah, one more thing, you can use n=scan() instead of a function definition to read from stdin; that'll get you under 100

Fails for input: 0

@Rift I've fixed it.

Jelly, 22 bytes
ŒcP€ḟ⁸ṢŒgLÞḢḢṭ
2,3Ç¡ị@

A monadic link, 1-indexed.
Try it online!
How?
ŒcP€ḟ⁸ṢŒgLÞḢḢṭ - Link 1, add the next number: list, a  e.g. [2,3,6,12,18,24]
Œc             - unordered pairs                            [[2,3],[2,6],[2,12],[2,18],[2,24],[3,6],[3,12],[3,18],[3,24],[6,12],[6,18],[6,24],[12,18],[12,24],[18,24]]
  P€           - product of €ach                            [6,12,24,36,48,18,36,54,72,72,108,144,216,288,432]
     ⁸         - chain's left argument, a                   [2,3,6,12,18,24]
    ḟ          - filter discard                             [36,48,36,54,72,72,108,144,216,288,432]
      Ṣ        - sort                                       [36,36,48,54,72,72,108,144,216,288,432]
       Œg      - group runs of equal elements               [[36,36],[48],[54],[72,72],[108],[144],[216],[288],[432]]
          Þ    - sort by:
         L     -   length                                   [[48],[54],[108],[144],[216],[288],[432],[36,36],[72,72]]
           Ḣ   - head                                       [48]
            Ḣ  - head                                       48
             ṭ - tack to a                                  [2,3,6,12,18,24,48]

2,3Ç¡ị@ - Link: number, i                              e.g. 7
2,3     - literal [2,3]                                     [2,3]
    ¡   - repeat i times:
   Ç    -   call last link (1) as a monad                   [2,3,6,12,18,24,48,54,96]
     ị@ - index into with swapped @rguments (with i)        48

CJam (32 bytes)
4,{_2m*{~>},::*1$-$e`$0=|}qi*-2=

Online demo with 0-indexing.
I'm not sure there's much to be done beyond a trivial translation of the spec with one exception: by starting with a list of [0 1 2 3] (instead of [2, 3]) I save one byte immediately on initialisation and another two by being able to do 0=| (adding just the new element because its frequency is 1 and is already in the list), but don't introduce any false elements because for every x in the list 0*x and 1*x are already in the list.

Python 2, 127 118 bytes
n=input()
l=[2,3]
exec't=sorted(x*y for i,x in enumerate(l)for y in l[i+1:]);l+=min(t,key=(l+t).count),;'*n
print l[n]

Try it online!

Mathematica, 154 bytes
simple modification of the code found at oeis link
(s={2,3};Do[n=Select[Split@Sort@Flatten@Table[s[[j]]s[[k]],{j,Length@s},{k,j+1,Length@s}],#[[1]]>s[[-1]]&&Length@#==1&][[1,1]];AppendTo[s,n],{#}];s[[#]])&

PHP, 130 bytes
0-indexed

for($r=[2,3];!$r[$argn];$r[]=$l=min($m)/2){$m=[];foreach($r as$x)foreach($r as$y)($p=$x*$y)<=$l|$y==$x?:$m[$p]+=$p;}echo$r[$argn];

Try it online!
Expanded
for($r=[2,3];!$r[$argn]; #set the first to items and loop till search item exists
$r[]=$l=min($m)/2){ # add the half of the minimum of found values to the result array
  $m=[]; # start with empty array
  foreach($r as$x) # loop through result array
    foreach($r as$y) # loop through result array
      ($p=$x*$y)<=$l|$y==$x? # if product is greater as last value and we do multiple two distinct values
        :$m[$p]+=$p; # add 2 times or more the product to array so we drop 36 cause it will be 144
}
echo$r[$argn]; # Output

PHP, 159 bytes
0-indexed

for($r=[2,3];!$r[$argn];$r[]=$l=min(array_diff_key($m,$d))){$d=$m=[];foreach($r as$x)foreach($r as$y)$x<$y?${dm[$m[$p=$x*$y]<1&$p>$l]}[$p]=$p:0;}echo$r[$argn];

Try it online!
PHP, 161 bytes
0-indexed

for($r=[2,3];!$r[$argn];$r[]=$l=min(array_diff($m,$d))){$d=$m=[];foreach($r as$x)foreach($r as$y)$x<$y?${dm[!in_array($p=$x*$y,$m)&$p>$l]}[]=$p:0;}echo$r[$argn];

Try it online!

Mathematica, 140 bytes
(t=1;s={2,3};While[t<#,s=AppendTo[s,Sort[Select[First/@Select[Tally[Times@@@Permutations[s,{2}]],#[[2]]==2&],#>Last@s&]][[1]]];t++];s[[#]])&

MATL, 25 bytes
3:i:"t&*9B#u2=)yX-X<h]2_)

Try it online!
Explanation
3:     % Push [1 2 3]. Initial array of MU numbers, to be extended with more numbers
i:     % Input n. Push [1 2 ... n]
"      % Do this n times
  t    %   Duplicate array of MU numbers so far
  &*   %   Matrix of pair-wise products
  9B   %   Push 9 in binary, that is, [1 0 0 1]
  #    %   Specify that next function will produce its first and fourth ouputs
  u    %   Unique: pushes unique entries (first output) and their counts (fourth)
  2=   %   True for counts that equal 2
  )    %   Keep only unique entries with count 2
  y    %   Duplicate (from below) array of MU numbers so far
  X-   %   Set difference
  X<   %   Minimum. This is the new MU number
  h    %   Concatenate vertically horizontally to extend the array
]      % End
2_     % Push 2 negated, that is, -2
)      % Get entry at position -2, that is, third-last. Implicitly display

JavaScript (ES6), 119 118 117 bytes
A recursive function that takes a 0-based index.
f=(n,a=[2,m=3])=>a[n]||a.map(c=>a.map(d=>c<d&(d*=c)>m?b[d]=b[d]/0||d:0),b=[])|f(n,a.push(m=b.sort((a,b)=>a-b)[0])&&a)

How?
At each iteration of f(), we use the last term m of the sequence and an initially empty array b to identify the next term. For each product d > m of two earlier distinct MU-numbers, we do:
b[d] = b[d] / 0 || d

and then keep the minimum value of b.
The above expression is evaluated as follows:
b[d]               | b[d] / 0  | b[d] / 0 || d
-------------------+-----------+--------------
undefined          | NaN       | d
already equal to d | +Infinity | +Infinity
+Infinity          | +Infinity | +Infinity

This guarantees that products which can be expressed in more than one way will never be selected.
Formatted and commented
f = (n, a = [2, m = 3]) =>           // given: n = input, a[] = MU array, m = last term
  a[n] ||                            // if a[n] is defined, return it
  a.map(c =>                         // else for each value c in a[]:
    a.map(d =>                       //   and for each value d in a[]:
      c < d &                        //     if c is less than d and
      (d *= c) > m ?                 //     d = d * c is greater than m:
        b[d] = b[d] / 0 || d         //       b[d] = either d or +Infinity (see 'How?')
      :                              //     else:
        0                            //       do nothing
    ),                               //   end of inner map()
    b = []                           //   initialization of b[]
  ) |                                // end of outer map()
  f(                                 // do a recursive call:
    n,                               //   - with n
    a.push(                          //   - push in a[]:
      m = b.sort((a, b) => a - b)[0] //     m = minimum value of b[]
    ) && a                           //     and use a[] as the 2nd parameter
  )                                  // end of recursive call

Demo

f=(n,a=[2,m=3])=>a[n]||a.map(c=>a.map(d=>c<d&(d*=c)>m?b[d]=b[d]/0||d:0),b=[])|f(n,a.push(m=b.sort((a,b)=>a-b)[0])&&a)

for(var n = 0; n < 10; n++) {
  console.log('MU[' + n + '] = ' + f(n));
}

Perl 6, 96 bytes
{(2,3,{first *∉@_,@_.combinations(2).classify({[*]
$_}).grep(*.value==1)».key.sort}...*)[$_]}

Try it online!

2, 3, { ... } ... * is an infinite sequence where each element starting with the third is computed by the brace-delimited code block.  Since the code block takes its arguments via the slurpy @_ array, it receives the entire current sequence in that array.
@_.combinations(2) is a sequence of all 2-element combinations of @_.
.classify({ [*] $_ }) classifies each 2-tuple by its product, producing a hash where the products are the keys and the values are the list of 2-tuples that have that product.
.grep(*.value == 1) selects those key-value pairs from the hash where the value (ie, the list of pairs having that key as a product) has a size of 1.
».key selects only the keys of each pair.  This is the list of products that arise from only one combination of factors of the current sequence.
.sort sorts the products numerically.
first * ∉ @_, ... finds the first of those products that has not already appeared in the sequence.

Haskell, 117 115 113 bytes
n x=[a*b|[a,b]<-mapM id[1:x,x]]
d x=minimum[a|a<-n x,2==sum[1|b<-n x,b==a]]:x
l x|x<3=x+1:[2]|1>0=d$l$x-1
(!!0).l

Try it online!

The first line can be written as a useful idiom for operator cartesian product: n x=(*)<$>x<*>1:x

Python 3 2, 167 139 136 133 123 121 120 118 bytes
a=[2,3];exec'p=[x*y for x in a for y in a if x-y];a+=min(q for q in p if p.count(q)+(q in a)<3),;'*input();print a[-2]

Try it online!

Thanks to @Mr.Xcoder and @LeakyNun for improvements!

159 bytes, just by removing unnecessary spaces and brackets.

@Mr.Xcoder Thanks for the improvements. I'm not sure changing p.count(q)==1 to p.count(q)>0 is valid, because that's the code that ensures the "in exactly one way" condition of the challenge.

p.count(q)-~(q in a)<=3 is equivalent to p.count(q)+(q in a)<3

source: Stack Exchange

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

sort: votes


text:
Create your original sequence challenge
There are lots of challenges that just pick a sequence from oeis and ask you to print n-th number or first n numbers or whatever.
It's time to stop automate!
Task
Your task is to parse a sequence page from oeis.org and print its index, description and example values. The page's index should be chosen and random, selected uniformly from the range [1-289361].
Example outputs (formatted with newline as a separator):
A034434
Multiplicity of highest weight (or singular) vectors associated with character chi_46 of Monster module.
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 3, 7, 12, 21, 38, 60, 102, 165, 265, 416, 660, 1015, 1574, 2405, 3665, 5535, 8364, 12512, 18726, 27862, 41391, 61240, 90541, 133381, 196395, 288534, 423656, 621219, 910885, 1334634

A38246
Triangle whose (i,j)-th entry is binomial(i,j)*5^(i-j)*4^j.
1, 5, 4, 25, 40, 16, 125, 300, 240, 64, 625, 2000, 2400, 1280, 256, 3125, 12500, 20000, 16000, 6400, 1024, 15625, 75000, 150000, 160000, 96000, 30720, 4096, 78125, 437500, 1050000, 1400000, 1120000, 537600, 143360, 16384, 390625

A212813
Number of steps for n to reach 8 under iteration of the map i -> A036288(i), or -1 if 8 is never reached.
-1, -1, -1, -1, -1, -1, 1, 0, 2, 1, 2, 1, 3, 2, 3, 3, 4, 3, 3, 2, 3, 3, 3, 2, 3, 4, 2, 2, 4, 3, 4, 3, 4, 3, 4, 3, 5, 4, 5, 2, 5, 4, 5, 4, 2, 5, 3, 2, 4, 4, 4, 4, 3, 2, 5, 3, 4, 4, 5, 4, 5, 4, 3, 4, 4, 5, 5, 4, 3, 4, 5, 4, 4, 3, 3, 3, 4, 4, 4, 3, 4, 5, 5, 4, 4, 6, 5, 4, 4, 3, 4, 3, 5, 5, 4, 3, 6, 5, 4, 4, 5, 4, 4, 3, 4, 4, 4, 3, 5, 4, 6, 4, 5, 4, 5, 4, 3, 5, 4

A155181
a(n)=5*a(n-1)+a(n-2), n>2 ; a(0)=1, a(1)=4, a(2)=20 .
1, 4, 20, 104, 540, 2804, 14560, 75604, 392580, 2038504, 10585100, 54964004, 285405120, 1481989604, 7695353140, 39958755304, 207489129660, 1077404403604, 5594511147680, 29049960142004, 150844311857700, 783271519430504

A227356
Partial sums of A129361.
1, 2, 5, 10, 20, 36, 65, 112, 193, 324, 544, 900, 1489, 2442, 4005, 6534, 10660, 17336, 28193, 45760, 74273, 120408, 195200, 316216, 512257, 829458, 1343077, 2174130, 3519412, 5696124, 9219105, 14919408, 24144289

Example, ungolfed, python script:
import requests
import random
seq = 'A%s' % `random.randint(1,289361)`.zfill(6)
page = requests.get('http://oeis.org/%s' % seq)
print_next = False
content = []
for line in page.text.split('\n'):
    if print_next:
        print_next = False
        content.append(line)
    if '<td width="710' in line or '' in line:
        print_next = True
print seq
print content[0].lstrip()
print content[1].lstrip()[4:-5]

Rules

oeis.org states, that there are 289361 sequences right now. You should not try to parse pages with higher index.
Your program should uniformly choose a random page.
Your program may produced undefined behavior if it randomly chooses to parse an oeis page that is reserved or does not contain a sequence (see A288145)
Trailing white space is acceptable.
You must remove leading white space and the outermost html tags from each line of your output. (i.e., the example values are wrapped in <tt><tt/>, which must be removed, but the description sometimes contains tags such as <href> within the text. Such tags do not need to be handled (see A195534)).
You do not have to handle html escapes (see A219225)
You do not need to print leading zeroes in the index. (e.g. A1 and A000001 are both acceptable). This is because oeis.org itself allows you to do either, as in, http://oeis.org/A1 and http://oeis.org/A000001 are both valid URLs that point to the same page.
You may return/print the "lines" in one of the following formats:

As an array/list with three elements
As a string separated by some separator. However, the separator must not appear in any of the "lines" (the index, the description, or the example values). In addition, this separator must be consistent (you can't select a separator based on the content of the "lines").

The meta definition of uniformly random applies.
Standard loopholes apply.

This is code-golf, so shortest code (in bytes) wins.

Very related

@WheatWizard Yep. But task is different

This needs to specify precisely what formats are permitted and deal with edge cases including particularly gaps in the sequence IDs (e.g. http://oeis.org/A288145 )

@PeterTaylor I think, that edits made to post are specify it all

CJam (61 bytes)
"oeis.org/search?fmt=text&q=id:A"289361mr)s+gN%{1=s"ISN"&},N*

No online demo available because the use of g is restricted by both online testers for security reasons.
I'm still not convinced that the output format is clearly specified, but since I seem to be in a minority I'm exploiting its gaps for golfiness. There is no leading whitespace or outer HTML tag to remove in the output.

Python 3, 198 bytes
from requests import*
import random,html
s='A%s'%str(random.randint(1,289355))
print(s)
t=get('http://oeis.org/%s'%s).text.split('\n')
print(html.unescape(t[95].strip()))
print(t[116].strip()[4:-5])

This works for everything I've tried so far, but since it hard-codes the line indices, please tell me if it breaks on anything (that isn't an unfilled reserved spot).
-9 bytes thanks to Dead Possum

You may remove .zfill(6). Turns out, that leading zeros are not necessary

@DeadPossum Oh cool, thanks.


text:
Java is to JavaScript as Car is to Carpet
Title stolen inspired by Greg Hewgill's answer to What's the difference between JavaScript and Java?
Introduction
Java and JavaScript are commonly used languages among programmers, and are currently the most popular tags on Stack Overflow. Yet aside from similar names, the two have almost nothing in common.
In honor of one of programming's most infamous debates, and inspired by my recent frustrations in tag searching, I propose the following:
Challenge
Write a program which takes in a string as input. Return car if the string begins with "Java" and does not include "JavaScript". Otherwise, return carpet.
Example Input and Output
car:
java
javafx
javabeans
java-stream
java-script
java-8
java.util.scanner
java-avascript
JAVA-SCRIPTING
javacarpet

carpet:
javascript
javascript-events
facebook-javascript-sdk
javajavascript
jquery
python
rx-java
java-api-for-javascript
not-java
JAVASCRIPTING

Notes

Input matching should be case insensitive
Only possibilities for output should be car or carpet
Imaginary bonus points if your answer uses Java, JavaScript, or Regex
Alternate Title: Java is to JavaScript as ham is to hamster

The new [tag:pattern-matching] tag needs a wiki. Please contribute if you can

Depending on the order things are done in, javacarpet might catch bugs that the existing test cases don't.

If you get imaginary bonus points if your answer uses Java, Javascript, or Regex, does that make such solution's bytecount complex? ;)

Alternate Title: Java is to JavaScript as ham is to hamster Actually, the "ham" in "hamster" is cognate to the food "ham". The food "ham" is pig meat, and the term "hamster" is derived from the related animal, the guinea pig, whose meat replaced pigs meat on long sea voyages as the animals were easier to raise on a ship.

Java/JavaScript Polyglot, 108 107 106 bytes
//\u000As->s.matches("(?i)(?!.*javascript)java.*"/*
a=>/(?!.*javascript)^java/i.test(a/**/)?"car":"carpet"

Run as Java
//\u000As->s.matches("(?i)(?!.*javascript)java.*"/*
a=>/(?!.*javascript)^java/i.test(a/**/)?"car":"carpet"

Try it online!
Note: don't trust the highlight as it's incorrect. The real Java, properly interpreted looks like below because \u000A is interpreted in the very first step of the compilation as \n, de facto ending the comment that started with the line comment (//).
//
s->s.matches("(?i)(?!.*javascript)java.*"/*
a=>/(?!.*javascript)^java/i.test(a/**/)?"car":"carpet"

Run as JavaScript
//\u000As->s.matches("(?i)(?!.*javascript)java.*"/*
a=>/(?!.*javascript)^java/i.test(a/**/)?"car":"carpet"

Credits to @CowsQuak for the JS version.

let f=

//\u000As->s.matches("(?i)(?!.*javascript)java.*"/*
a=>/(?!.*javascript)^java/i.test(a/**/)?"car":"carpet"

var a=["java","javafx","javabeans","java-stream","java-script","java-8","java.util.scanner","javascript","java-avascript","javascript-events","facebook-javascript-sdk","javajavascript","jquery","python","rx-java","java-api-for-javascript","not-java"];

for(var s of a) console.log(s.padStart(a.reduce((x,y)=>x.length>y.length?x:y).length) + "=>" + f(s));

How many imaginary bonus points for this answer?
-1 byte thanks to @Nevay in the Java answer.

This isn't competitive in JavaScript or Java. I'm not even convinced it's a serious contender, which is a requirement for all submissions.

@Dennis Thank you for your information. However I consider this as a polyglot entry. Is there any rule against polyglot entries when they aren't explicitly requested? I tried to golf this as much as possible. For instance, I tried to put both regexes together, but I couldn't get anything shorter than this (because of the two different albeit similar regexes, and their delimiter). It's also impossible to have the same variable definition because JavaScript doesn't allow a new line between a and =>. I tried to stay in the spirit of golfing. If I did something wrong, please tell me?

@Dennis IMHO "Java/JavaScript polyglot" counts as its own language, in which case this is very competitive.

@OlivierGrégoire I'm not saying this isn't a well-golfed polyglot submission, but it's debatable if there should be polyglot submissions to non-polyglot challenges in the first place. They came up as part of the Can serious contenders do more than the challenge asks for? discussion, but I don't think there's a clear consensus on this particular topic. Personally, I'm not in favor.

@Dennis Thank you for your insights, I now understand what you meant. Should this answer be tagged as "non-competitive", according to you? On the other hand, while I'm not speaking for all polyglot answers (this is my first ever), this one has the special meaning that the challenge speaks about both Java and JavaScript, and that the "imaginary bonus points" were explicitly awarded for Java, JavaScript and regex answers before I wrote this answer. Java and regex can be combined, JavaScript and regex can be combined, why not all together? Anyways, I don't mind marking this as non-competitive.

We don't mark answers anymore; for this particular reason, we never did. I'm not saying this answer isn't a serious contender (it isn't in my personal opinion), but if it weren't, it would have to be removed.

JavaScript, 50 49 bytes
Saved 1 byte thanks to @ValueInk by rearranging the regex
a=>/javascript|^(?!java)/i.test(a)?"car":"carpet"

Test snippet

let f=

a=>/javascript|^(?!java)/i.test(a)?"carpet":"car"

var a=["java","javafx","javabeans","java-stream","java-script","java-8","java.util.scanner","java-avascript","javascript","javascript-events","facebook-javascript-sdk","javajavascript","jquery","python","rx-java","java-api-for-javascript","not-java"];

for(var s of a) console.log(s.padStart(a.reduce((x,y)=>x.length>y.length?x:y).length) + "=>" + f(s));

I was going to steal your regex but that would have made my answer longer :o nice answer though

Now we just need a java answer.

We have a Java answer, but... I came to the roughly same regex...

alternatively: /^java(?!script)/i

@Andrea Nope: fails on "javajavascript".

@OlivierGrégoire ah, damn, that one seems unfair

If you switch the ternary around, /javascript|^(?!java)/i has been working for me and is 1 byte shorter.

@ValueInk Thanks for the tip!

Java (OpenJDK 8), 92 82 72 58 57 bytes
s->s.matches("(?i)(?!.*javascript)java.*")?"car":"carpet"

Try it online!
1 byte saved thanks to @Nevay!

You can omit the caret as String#matches attempts to match the entire string.

C (only calling puts), 131 bytes
f(int*s){char r[]="carpet";~*s&'AVAJ'||(r[3]=0);for(;*s&255;*(int*)&s+=1)~*s&'AVAJ'||~s[1]&'IRCS'||~s[2]&'TP'||(r[3]='p');puts(r);}

It does have its problems, but it passes all of the testcases provided :)
g(int* s)
{
  char r[] = "carpet";
  ~*s&'AVAJ' || (r[3]=0);
  for(;*s & 255; *(int*)&s +=1)
    ~*s&'AVAJ' || ~s[1]&'IRCS' || ~s[2]&'TP' || (r[3]='p');
  puts(r);
}

Imaginary bonus points if your answer uses Java, Javascript, or Regex

well... no thanks

Python 2, 68 bytes
k=input().lower();print'car'+'pet'*(k[:4]!='java'or'javascript'in k)

Try it online!
-11 bytes thanks to notjagan
-2 bytes thanks to Dennis

11 bytes shorter.

Slightly different 81 byte solution

@Justin That too. Nice.

If you switch to Python 2, you can save 2 bytes with a full program.

@Dennis Nice, thanks.

Possibly a Pythonic meta question, but since ; saves no bytes over \n, should one use \n for readability or it visually better "golfed" if it's on one line?

@LukeSawczak It makes no difference to golfability so I choose \n for readability. It doesn't matter but sometimes ; is more golfy when indents exist.

@HyperNeutrino That's true. Just noticing that you used ; here.

@LukeSawczak Oh I didn't even realize that :P I was using Java right before that and in Java ; is required so I since I have to use it anyway the newline is unnecessary :P That's why I used it.

05AB1E, 21 bytes
lD'¦‚å≠sη'îáå*„¾„ƒ´#è

Try it online!

lD“¦‚“åi“¾„“ë“îá“åi…carë  3 bytes more and 1 hour late :(. Nice job.

Jelly, 27 bytes
,“Ẋṣ“®Ẓȷ»ŒlwÐ€/Ḅn2‘×3“¢Ẹị»ḣ

Try it online!

C#, 80 78 bytes
s=>(s=s.ToLower()).StartsWith("java")&!s.Contains("javascript")?"car":"carpet"

I think the most readable language here is C#

@sepehr You mean you see sharp with C#. (Do I get a bonus for dumb comments)

EXCEL Google Sheets, 89 86 Bytes
Saved 3 bytes thanks to Taylor Scott
=LEFT("carpet",6-3*ISERR(SEARCH("javascript",A1))+3*ISERR(IF(SEARCH("java",A1)=1,1,1/0

Takes an input on A1
Explanation
=LEFT("carpet",6-3*ISERR(SEARCH("javascript",A1))+3*ISERR(IF(SEARCH("java",A1)=1,1,1/0)))

 SEARCH("javascript",A1)        #Case-Insensitive Find, returns error if not found
 ISERR(                         #Returns string true if error, False if not
 3*ISERR(                       #Forces TRUE/False as integer, multiplies by 3
 IF(SEARCH("java",A1)=1,1,1/0)  #If java found, returns integer. if 1, java begins string
                                #so returns 1, which will be turned into 0 by iserr.
                                #Else returns 1/0, which will be turned into 1 by iserr.
 LEFT(                          #Returns digits from the left, based upon count.

I believe that you can replace the Searches with Finds for -2 bytes and that that could be further translated to a google sheets formula for -3 bytes by not closing the last three parens

Find is case sensitive, search is case insensitive.  But those last 3 bytes are a good idea!

Why the swap from Excel to Google Sheets?

Removing the last 3 parens saves 3 bytes.  Excel would just throw an error and put them in for you anyways.

Common Lisp, 131 125 bytes
(lambda(s)(format()"car~@[pet~]"(or(<(length s)4)(not(#1=string-equal"java"(subseq s 0 4)))(search"javascript"s :test'#1#))))

Try it online!
Size reduced thanks to the #n= “trick” of Common Lisp.
Explanation
(lambda (s)                 ; anonymous function
  (format                   ; use of format string to produce the result
    ()                      ; the result is a string
    "car~@[pet~]"           ; print "car", then print "pet" when:
    (or (< (length s) 4)    ; the string is less then 4 characters or
        (not (string-equal "java" (subseq s 0 4)))     ; does not start with java or
        (search "javascript" s :test 'string-equal)))) ; contains javascript

Retina,  44  37 bytes
Ai`^(?!.*javascript)java
.+
pet
^
car

Thanks to @MartinEnder for golfing off 7 bytes!
Try it online!

vim, 58 bytes
gUU:s/.*JAVASCRIPT.*/Q/g
:s/^JAVA.*/car
:s/[A-Z].*/carpet

Try it online!

I think using the g command might be a little shorter, something like :g/\cjavascript/d :g!/^\cjava/d icarpet␛:s/pet..*.

Ruby, 42+1 = 43 bytes
Uses the -p flag.
$_="car#{"pet"if~/javascript|^(?!java)/i}"

Try it online!

C (tcc), 144 136 bytes
a;f(s){char*t=s;for(;*t;a=!strncmp(s,"java",4))*t=tolower(*t++);for(t=s;*t;)s=strncmp(t++,"javascript",10)&&s;puts(a*s?"car":"carpet");}

Try it online!
Unrolled:
a;
f(s)
{
    char *t = s;
    for (; *t; a = !strncmp(s, "java", 4))
        *t = tolower(*t++);
    for (t=s; *t;)
        s = strncmp(t++, "javascript", 10) && s;
    puts(a*s ? "car"  :"carpet");
}

Python 2, 69 bytes
f=input().lower().find
print'car'+'pet'*(f('java')!=~f('javascript'))

Currently 1 byte longer than the shortest Python 2 solution.
Try it online!

Excel VBA, 76 Bytes
Anonymous VBE immediate window function that takes input from range [A1] and outputs is car/carpet status to the VBE immediate window
Does not use RegExp
?"car"IIf(InStr(1,[A1],"Java",1)*(InStr(1,[A1],"JavaScript",1)=0),"","pet")

Nice use of vba! I thought a macro would have been shorter. Now I have proof.

JAISBaL, 36 bytes
℠℘(?!.*javascript)^java.*}͵Ucar½Upet

Verbose/explanation:
# \# enable verbose parsing #\
tolower                           \# [0] convert the top value of the stack to lowercase #\
split (?!.*javascript)^java.*}    \# [1] split the top value of the stack by (?!.*javascript)^java.*} #\
arraylength                       \# [2] push the length of the array onto the stack #\
print3 car                        \# [3] print car #\
!if                               \# [4] if the top value on the stack is falsy, skip the next statement #\
print3 pet                        \# [5] print pet #\

JAISBaL was my first attempt at designing a golfing language, so it's rather quirky... there's no matches or contains, regex or otherwise, so instead we have to split and check the resulting array length... because JAISBaL has a split-by-regex... but no other regex support.... because reasons.
Regex stolen borrowed from @Cows Quack's answer.

Excel, 84 bytes
="car"&IF(AND(ISERR(SEARCH("javascript",A1)),IFERROR(SEARCH("java",A1),2)=1),,"pet")

Python 3, 95 bytes
g=lambda s:(lambda r:'car' if r[:4]=='java' and 'javascript' not in r else 'carpet')(s.lower())

Try it online!
Yeah, it could be shorter but I wanted to try using a nested lambda!

Always good to experiment :) Note that you can save bytes around operators like and, or, if, else

Perl, 42 bytes
I believe the answer by stevieb has an incorrect output (tried that one myself - it returns car for 'javajavascript'). This should work:
say/^java/i&&!/javascript/i?'car':'carpet'

Bracmat, 66 bytes
(f=.pet:?b&@(low$!arg:(? javascript ?|java ?&:?b|?))&str$(car !b))

Try it online!

Go, 134 bytes
import."strings"
func f(s string)string{T,o:=ToLower,"car"
if Contains(T(s),"javascript")||!HasPrefix(T(s),"java"){o+="pet"}
return o}

Attempt This Online!

GolfScript, 53 49 44 bytes
{32|}%"java"/(,\{6<"script"=+}/"carpet".3<if

Try it online!
This was my second GolfScript submission so after writing a couple more I was able to revisit this and shave a couple bytes.
Previously, this mapped over a list, then summed it, then added it to a base value. Now, it just loops over the list, adding to the base value on each iteration.
Here's an explanation of how the code works:
{32|}%           # Convert the string to lowercase

"java"/          # Split on "java".
(,               # Extract the first item, and push its length
                 # (0 iff string starts with java).
\                # Swap so the rest of the list is on top of the stack.

{6<"script"=+}/  # Check if any start with "script":
{            }/  #   Loop over each item:
 6<              #     Take the first 6 characters.
   "script"=     #     Are they equal to "script"? (0 or 1)
            +    #     Add this to the top of the stack.

# After this loop, the stack will be 0 iff the string started
# with "java" and does not contain "javascript".

"carpet".3<     # Push "carpet" and its first 3 characters.
if              # If the value is 0, "car", otherwise "carpet".

Lua, 88 bytes
s=io.read():lower()print(s:sub(1,4)=='java'and not s:find'javascript'and'car'or'carpet')

Attempt This Online!

Fails for input Javascript, but moving the call to :lower() to just after io.read() seems to fix it. Also, you can save 3 bytes by removing the whole concatenation of 'car' and just doing and'car'or'carpet'.

Just FYI this is still wrong after your edit, the :lower() needs to be moved to just after io.read() so cases like JAVASCRIPTING -> carpet  work correctly

Perl, 98 84 62 Bytes
sub a{"car".($_[0]=~/javascript/i||$_[0]!~/^java/i?'pet':'');}

Try it online!
Thanks to bytepusher

Welcome to the site! I don't know any perl, but it looks like there is a lot of whitespace you could remove. Also, if you're looking for more ways to shorten it, there's a bunch of tips here.

@DJMcMayhem Thank you, I think the entire logic can be changed to make it even shorter, but I haven't figured it out

Just some hints (without changing your solution too much):
You can replace the return $b; with just $b;. Perl always returns the last evaluated statement. Since we don't care about warnings, you can even drop the ';' to $b}. You don't need the brackets around the if. If you use || instead of or, you can save a whitespace after the regex.

You can also remove the () around the first lc, but need a space after if then. If you use !~ instead of ! =~ the second condition can be lc$_[0]!~. ->sub a{$b="car";$b.="pet"if lc$[0]=~/javascript/||lc$[0]!~/^java/;$b}. Using the ternary ops brings it down one more sub a{$b="car";$b.="pet"if lc$[0]=~/javascript/||lc$[0]!~/^java/;$b}`

Not to forget - no need for lc when you have the regex ignore case switch,
down another 2 :) $_[0] =~//i||$_[0]!~//i. And finally, why a variable?
sub a{"car".($_[0]=~/javascript/i||$_[0]!~/^java/i?'pet':'');}
should do fine :). And now: perl will be nice and let you use $_[0] w/o specifying it (though not with !~): sub a{"car".(/javascript/i||!/^java/i?'pet':'')} -> 48 :)

Mathematica, 82 bytes
regex
If[#~StringMatchQ~RegularExpression@"(?i)(?!.*javascript)^java.*","Car","Carpet"]&

Batch, 91 bytes
@set/ps=
@set t=%s:~0,4%
@if "%t:java=%%s:javascript=%"=="%s%" (echo car)else echo carpet

Takes input on STDIN. Batch doesn't have a case insensitive comparison operator but it does have case insensitive string replacement so I can assign a temporary to the first four characters and then case insensitively replace java, which should then result in the empty string. Meanwhile I case insensitively replace javascript in the original string, which should leave it unchanged.

Lua, 96 bytes
function(x)return x:lower():match"^java"and not x:lower():match"javascript"and"car"or"carpet"end

Dart VM, 104 bytes 102 bytes
main(p){p=p[0].toLowerCase();print("car${p.indexOf('java')==0&&p.indexOf('javascript')<0?'':'pet'}");}

Explanation:
Degolfed:
main(p)
{
    p = p[0].toLowerCase();
    print("car${p.indexOf('java') == 0 && p.indexOf('javascript') < 0 ? '' : 'pet'}");
}

We have our usual main function
We replace p with p[0].toLowerCase(); so that we don't have to declare a new variable (var plus a space would be 4 extra bytes)
We then proceed to do the actual printing
We print car unconditionally and we use inline statements for checking whether to print pet after it or not. If it has the string 'java' at index 0 and does not have 'javascript' in it, we do nothing (we actually append an empty string but it does not have any effect) and otherwise we append pet.

Rust, 97 bytes
let s=if Regex::new(r"^javascript|^!java$").unwrap().is_match("javascript"){"carpet"}else{"car"};

I'm pretty sure that there is a shorter solution but it's my first try :)

PowerShell, 81 bytes
$a={param($s)$s.StartsWith('java')-and(!s.contains('javascript'))?'car':'carpet'}

Try it online!

Perl 5 -p, 38 + 1 = 39 bytes
$_=car.pet x!(/^java/i*!/javascript/i)

Try it online!

Perl, 36 bytes
say/^java(?!script)/i?"car":"carpet"

Run it as such:
perl -nE 'say/^java(?!script)/i?"car":"carpet"' java.txt

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