text:
The first n numbers without consecutive equal binary digits
The sequence contains the decimal representation of the binary numbers of the form: 10101..., where the n-th term has n bits.
The sequence is probably easiest to explain by just showing the relationships between the binary and decimal representations of the numbers:
0       ->  0
1       ->  1
10      ->  2
101     ->  5
1010    ->  10
10101   ->  21
101010  ->  42

Challenge:
Take an input integer n, and return the first n numbers in the sequence. You may choose to have the sequence 0-indexed or 1-indexed.
Test cases:
n = 1   <- 1-indexed
0

n = 18
0, 1, 2, 5, 10, 21, 42, 85, 170, 341, 682, 1365, 2730, 5461, 10922, 21845, 43690, 87381

Explanations are encouraged, as always.
This is OEIS A000975.

Given your own MATL solution, is it acceptable to output the result in reverse order?

Yes, as long as it's sorted. @Shaggy

Pushing my luck here, but would this output format be acceptable [85,[42,[21,[10,[5,[2,[1,0]]]]]]]?

Python 2, 36 bytes
lambda n:[2**i*2/3for i in range(n)]

Try it online! Explanation: The binary representation of \$\frac{2}3\$ is 0.101010101... so it simply remains to multiply it by an appropriate power of 2 and take the integer portion.

Too bad it's January 2018, otherwise I would have nominated it for Best mathematical insight for the Best of PPCG 2017. Hopefully I still remember it at the start of 2019. ;p

@KevinCruijssen this is the best I've seen out of all https://codegolf.stackexchange.com/a/51574/17360

@KevinCruijssen don't forget!

@BassdropCumberwubwubwub Thanks for the reminder, because I had indeed forgot about it completely! It had been added to the nominations.

05AB1E, 4 bytes
2 bytes saved using Neil's 2/3 trick
Lo3÷

Try it online!
Explanation
L      # push range [1 ... input]
 o     # raise 2 to the power of each
  3÷   # integer division of each by 3

05AB1E, 6 bytes
TRI∍ηC

Try it online!
Explanation
T        # push 10
 R       # reverse it
  I∍     # extend to the lenght of the input
    η    # compute prefixes
     C   # convert each from base-2 to base-10

Jelly, ... 4 bytes
Thanks miles for -1 byte!
ḶḂḄƤ

Try it online!
Explanation:
Ḷ     Ḷowered range, or UnḶength. Get [0, 1, 2, 3, ..., n-1]
 Ḃ    Ḃit. Get the last bit of each number. [0, 1, 0, 1, ...]
   Ƥ  for each Ƥrefixes [0], [0, 1], [0, 1, 0], [0, 1, 0, 1], ...
  Ḅ   convert it from Ḅinary to integer.

Jelly, 4 bytes
Jonathan Allan's version.
Ḷ€ḂḄ

Try it online!
Ḷ     Ḷowered range, or UnḶength.
 €    Apply for €each. Automatically convert the number n
      to the range [1,2,..,n]. Get [[0],[0,1],[0,1,2],..].
  Ḃ   Ḃit. Get the last bit from each number.
      Current value: [[0],[0,1],[0,1,0],..]
   Ḅ  Convert each list from Ḅinary to integer.

A version based on Neil's 2/3 trick gives 5 bytes, see revision history.

ḶḂḄƤ prefix quick was made for this

No need for the prefix quick even - Ḷ€ḂḄ would also work.

MATL, 5 bytes
:WI/k

Based on Neil's answer.
Explanation
:       % Implicit input, n. Push range [1 2 ... n]
W       % 2 raised to that, element-wise. Gives [2 4 ...2^n]
I       % Push 3
/       % Divide, element-wise
k       % Round down, element-wise. Implicit display

Try it online!

MATL, 9 bytes
:q"@:oXBs

Try it online!
Explanation
:       % Implicit input n. Range [1 2 ... n]
q       % Subtract 1, element-wise: gives [0 1 ... n-1]
"       % For each k in [0 1 ... n-1]
  @     %   Push k
  :     %   Range [1 2 ... k]
  o     %   Modulo 2, element-wise: gives [1 0 1 ...]
  XB    %   Convert from binary to decimal
  s     %   Sum. This is needed for k=0, to transform the empty array into 0
        % Implicit end. Implicit display

Python 3, 68 61 54 48 43 bytes
c=lambda x,r=0:x and[r]+c(x-1,2*r+~r%2)or[]

Thanks to user202729 for helping save 19 bytes and ovs for helping save 6 bytes.
Try It Online

Thanks for that -1 byte. And I think I can't replace if else with and or?

Okay done that already.

Because x == 0 is equivalent to not x if x is an integer, swap the operands (i.e., x if c else y = y if not c else x) will save some more bytes.

You can also drop i%2 and use 1-r%2 instead

Or ~r%2. (4 more to go)

But wouldn't that increase one byte instead?

Then you don't need to keep track of i.

Yeah. 7 more bytes gone.

48 bytes

Now you also don't need to keep track of s. Just drop it.

Python 2, 45 37 36 bytes
-3 bytes thanks to user202729
-1 byte thanks to mathmandan
s=0
exec"print s;s+=s+~s%2;"*input()

Try it online!

Doubling s is the same as adding s to itself, so I believe you could do s+=s+~s%2 to save a byte.

Ruby, 26 bytes
->n{(1..n).map{|i|2**i/3}}

Try it online!
Beats all the older ruby answers.
Explanation
1/3 in binary looks like 0.01010101..., so If you multiply it by powers of two, you get:
n| 2^n/3
-+---------
1|0.1010101...
2|01.010101...
3|010.10101...
4|0101.0101...
5|01010.101...
6|010101.01...

But Ruby floors the numbers on int division, giving me the sequence I need.

Husk, 7 bytes
mḋḣ↑Θİ¬

Try it online!
1-based, so input n gives the first n results.
Explanation
     İ¬   The infinite list [1, 0, 1, 0, 1, ...]
    Θ     Prepend a zero.
   ↑      Take the first n elements.
  ḣ       Get the prefixes of that list.
mḋ        Interpret each prefix as base 2.

Haskell, 47 40 53 49 44 40 34 bytes
-4 bytes thanks to user202729
-6 bytes thanks to Laikoni
(`take`l)
l=0:[2*a+1-a`mod`2|a<-l]

Try it online!

You can replace otherwise with e.g. 1>0 (otherwise == True)

To golf it even more, you can use the guard for assigning something, e.g. like this: Try it online!

PS: Also check out tips for golfing in haskell as well as our haskell-chatroom of monads and men.

You need to make a function that returns the first n elements of the list where n is the argument.

Must have missed that. Fixed

Your last line can be shortened to the anonymous function (`take`l): Try it online!

The map can be replaced by a list comprehension: l=0:[2*a+1-a`mod`2|a<-l] Try it online!

@Laikoni I'm fairly new to this, do I understand it correctly that anonymous functions are sufficient for Code-Golf?

Yes, exactly. I can recommend to have a look at our Guide to Golfing Rules in Haskell, which tries to capture the current consensus on what is allowed and what isn't.

APL (Dyalog), 7 bytes
⌊3÷⍨2*⍳

Try it online!

APL (Dyalog), 11 bytes
(2⊥2|⍳)¨1+⍳

Try it online!
Uses ⎕IO←0.

Returns one-too-many terms. Run under ⎕IO←0 (but claim it is 1-indexed!) and change 0, to 1+: (2⊥2|⍳)¨1+⍳

Perl v5.10 -n, 24+1 bytes
-3 bytes thanks to Nahuel Fouilleul!
say$v=$v*2|$|--while$_--

Try it online!
Same logic as my Ruby version, but shorter because perl is more concise. For some odd reason, print wouldn't do a seperator (dammit!), so I had to use say from v5.10; in order for this to run, I'm not sure how to score this, so I'm leaving it out for now?...
Explanation
say    # Like shouting, but milder.
  $v = $v*2 | $|-- # Next element is this element times 2 bitwise-OR
                   # with alternating 0 1 0 1..., so 0b0, 0b1, 0b10, 0b101...
                   # $. is OUTPUT_AUTOFLUSH, which is initially 0 and
                   #   setting all non-zero values seem to be treated as 1
  while $_-- # do for [input] times

for the scoring i would say: 27 + 1 (-n) = 28 bytes, because to run a perl one-liner, one should use -e and to use 5.10 you just need to use -E, which is the same length

can save 3 bytes using $|-- instead of ($.^=1)

Haskell, 33 bytes
l=1:0:l
($scanl((+).(2*))0l).take

Try it online!

APL (Dyalog Unicode), 11 bytesSBCS
Assumes ⎕IO (Index Origin) to be 0, which is default on many systems. Anonymous tacit prefix function. 1-indexed.
(2⊥⍴∘1 0)¨⍳

Try it online!
⍳ ɩndices 0…n−1
(…)¨ apply the following tacit function to each
 ⍴∘1 0 cyclically reshape the list [1,0] to that length
 2⊥ convert from base-2 (binary) to normal number

C, 81 55 59 bytes
1 indexed.
i,j;f(c){for(i=j=0;i<c;)printf("%d ",i++&1?j+=j+1:(j+=j));}

Full program, less golfed:
i;j;main(c,v)char**v;{c=atoi(*++v);for(;i<c;i++)printf("%d ",i&1?j+=j+1:(j+=j));}

Try it online!
EDIT 2: I was under the assumption that functions didn't need to be reusable now that I think of it, it makes perfect sense that they would have to be reusable :P
EDIT: I was under the misconception that I had to include the entire program in the answer, turns out I only needed the function that does it. That's nice.
I'm decently sure I can shave off a few bytes here and there. I've already employed a few tricks. A large chunk of the program is dedicated to getting the argument and turning it into an int. This is my first code golf. If I'm doing anything wrong tell me :P

Welcome to PPCG! :) I'm not a C guy but you may be able to glean some hints from Steadybox's solution.

Ok that makes more sense now, I've included the entire program when all I need is a function and the rest can be done in a footer. I guess this can be significantly improved then.

Welcome to PPCG! You can save a byte by removing i++ and changing i&1 to i++&1. Also, although as global variables i and j are initialized to zero initially, they need to be initialized inside the function, because function submissions have to be reusable.

Oh thanks for the tip! That makes sense now. Will make those edits

Our rules for how to score function is, if a header include #include<...> is required for the function to work correctly, it should be included in the bytecount. For C that's often not a problem, because most functions work without including header anyway. Just a note.

You can eliminate the duplicate j+= part, saves 5 bytes.

Even better, it's possible to save 2 more bytes, eliminating the ternary entirely.

How does that work?

50 bytes: i,j;f(c){for(i=j=0;i<c;)printf("%d ",j+=j+i++%2);} Try it online!

Alright steadybox, I don't think that's going any lower. Super impressive

J, 9 bytes
[:#.\2|i.

How it works?
i. - list 0..n-1
2| - the list items mod 2
\ -  all prefixes
#. - to decimal
[: - caps the fork (as I have even number (4) of verbs)
Try it online!

Brain-Flak, 36 bytes
{([()]{}<((({}<>)<>){}([{}]()))>)}<>

Try it online!
Explanation:
The next number in the sequence is obtained by n*2+1 or n*2+0.
{([()]{}< Loop input times
  (
   (({}<>)<>){} Copy n to other stack; n*2
   ([{}]())  i = 1-i
  ) push n*2 + i
>)} End loop
<> Output other stack

Retina, 28 bytes
)K`0
"$+"+¶<`.+
$.(*__2*$-1*

Try it online!
0-based, so input n gives the first n+1 results.
Explanation
Uses the recursion from OEIS:
a(n) = a(n-1) + 2*a(n-2) + 1

Let's go through the program:
)K`0

This is a constant stage: it discards the input and sets the working string to 0, the initial value of the sequence. The ) wraps this stage in a group. That group itself does nothing, but almost every stage (including group stages) records its result in a log, and we'll need two copies of the 0 on that log for the program to work.
"$+"+¶<`.+
$.(*__2*$-1*

There's a bunch of configuration here: "$+"+ wraps the stage in a loop. The "$+" is treated as a substitution, and $+ refers to the program's input, i.e. n. This means that the loop is run n times.
Then ¶< wraps each iteration in an output stage, which prints the stage's input with a trailing linefeed (so the first iteration prints the zero, the second iteration prints the first iteration's result and so on).
The stage itself replaces the entire working string with the substitution on the last line. That one makes use of an implicit closing parenthesis and implicit arguments for the repetition operator *, so it's actually short for:
$.($&*__2*$-1*_)

The stuff inside the parentheses can be broken up into three parts:

$&*_: gives a string of a(n-1) _s.
_: gives a single _.
2*$-1*_: gives a string of 2*a(n-1) _. The $-1 refers to the penultimate result in the result log, i.e. the loop iteration before the last. That's why we needed to copies of the zero on the log to begin with, otherwise this would refer to the program's input on the first iteration.

Then $.(…) measures the length of the resulting string. In other words, we've computed a(n) = a(n-1) + 1 + 2*a(n-2) by going through unary (not really though: $.(…) is lazy and doesn't actually evaluate its content if it can determine the resulting length directly through arithmetic, so this is even quite efficient).
The result of the final loop iteration (the n+1th element of the sequence) is printed due to Retina's implicit output at the end of the program.

Ruby 42 41 43 41 37 35 31 33 30 bytes
-2 bytes thanks to Unihedron
-3 bytes thanks to G B
->x{a=0;x.times{a-=~a+p(a)%2}}

Try it online!

Good work! I like your formula ^^

save 3 bytes: ->x{a=0;x.times{a-=~a+p(a)%2}}

Java 8, 115 81 80 52 bytes
n->{for(int i=2;n-->0;i*=2)System.out.println(i/3);}

Port of @Neil's Python 2 answer.
1-indexed and outputted directly, each value on a separated line.
Explanation:
Try it online.
n->{                           // Method with integer parameter and no return-type
  for(int i=2;                 //  Start integer `i` at 2
      n-->0;                   //  Loop `n` times:
      i*=2)                    //    Multiply `i` by 2 after every iteration
    System.out.println(i/3);}  //   Print `i` integer-divided by 3 and a new-line

Old 80 bytes answer:
n->{String t="",r=t;for(Long i=0L;i<n;)r+=i.parseLong(t+=i++%2,2)+" ";return r;}

1-indexed input and space-delimited String output
Explanation:
Try it online.
n->{                             // Method with integer parameter and String return-type
  String t="",r=t;               //  Temp and result-Strings, both starting empty
  for(Long i=0L;i<n;)            //  Loop from 0 to `n` (exclusive)
    r+=                          //   Append the result-String with:
       i.parseLong(        ,2);  //    Binary to integer conversion
                   t+=           //     append the temp-String with:
                      i  %2      //      current index `i` modulo-2
                       ++        //      and increase `i` by one afterwards
       +" ";                     //    + a space
  return r;}                     //  Return the result-String

Perl 6,  35 30 27 25  20 bytes
{[\~](0,+!*...*)[^$_]».&{:2(~$_)}}

Try it (35)
{(0,{$_*2+|($+^=1)}…*)[^$_]}

Try it (30)
{(⅓X*(2,4,8…2**$_))».Int}

Try it (30)
{(⅔,* *2…*)[^$_]».Int}

Try it (27)
{((2 X**1..$_)X/3)».Int}

Try it (25)
{(2 X**1..$_)Xdiv 3}

Try it (20)
Expanded:
{
 (
  2                  # 2
    X**              # cross to the power of
       1..$_         # Range from 1 to the input (inclusive)
            )

             Xdiv    # cross using integer divide
                  3  # by 3
}

C, 47 46 bytes
a;f(n){for(a=0;n--;a+=a-~a%2)printf("%d ",a);}

The accumulator a begins with zero.  At each step, we double it (a+=a) and add one if the previous least-significant bit was zero (!(a%2), or equivalently, -(~a)%2).
Test program
#include <stdlib.h>
#include <stdio.h>

int main(int argc, char **argv)
{
    while (*++argv) {
        f(atoi(*argv));
        puts("");
    }
}

Results
$ ./153783 1 2 3 4 5 6
0
0 1
0 1 2
0 1 2 5
0 1 2 5 10
0 1 2 5 10 21

Japt, 10 9 7 6 bytes
All derived independently from other solutions.
1-indexed.
õ!²mz3

Try it

Explanation
õ        :[1,input]
 !²      :Raise 2 to the power of each
   m     :Map
    z3   :Floor divide by 3

Try it

7 byte version
õ_ou ì2

Try it
õ            :[1,input]
 _           :Pass each through a function
   o         :[0,current element)
    u        :Modulo 2 on above
      ì2     :Convert above from base-2 array to base-10

9 byte version
õ_îA¤w)n2

Try it
õ            :[1,input]
 _           :Pass each through a function
   A         :10
    ¤        :Convert to binary
     w       :Reverse
  î          :Repeat the above until it's length equals the current element
      )      :Close nested methods
       n2    :Convert from binary to base-10

><>, 22 + 3 (-v flag) bytes
0:nao::1+2%++$1-:?!;$!

Try it online!
Explanation
The stack gets initialized with the loop counter.
0:nao                  : Push 0 to the stack, duplicate and print with a new line.
                         [7] -> [7, 0]
     ::1+              : Duplicate the stack top twice more then add 1 to it.
                         [7, 0] -> [7, 0, 0, 1]
         2%++          : Mod the stack top by 2 then add all values on the stack bar the loop counter.
                         [7, 0, 0, 1] -> [7, 1]
             $1-:?!;$! : Swap the loop counter to the top, minus 1 from it and check if zero, if zero stop the program else continue.

Python 2, 33 bytes
s=2
exec"print s/3;s*=2;"*input()

Try it online!

Python 2, 34 bytes
f=lambda n:n*[f]and[2**n/3]+f(n-1)

Try it online!
Returns in reverse order.

Thunno 2, 4 bytes
RO3÷

Attempt This Online!
Port of Neil's Python answer.
Explanation
RO3÷  # Implicit input       ->  5
R     # Push [1..input]      ->  [1,2,3,4,5]
 O    # Two power of each    ->  [2,4,8,16,32]
  3÷  # Integer divide by 3  ->  [0,1,2,5,10]
      # Implicit output

Actually, 14 bytes
r⌠;"10"*H2@¿⌡M

Try it online!
Explanation:
r⌠;"10"*H2@¿⌡M
r               range(0, input)
 ⌠;"10"*H2@¿⌡M  map (for n in range):
   "10"*          repeat "10" n times
  ;     H         first n characters
         2@¿      interpret as binary integer

Ruby -n, 32 30+1 bytes
Since we have exactly 1 line of input, $. is godly convenient!
EDIT: I'm amazed that I managed to outgolf myself, but it seems using -n which counts as 1 (by rule 2 in default special conditions, since Ruby can be run with ruby -e 'full program' (thus -n is 1) all instances of gets which is only used once can be golfed down 1 char this way; I believe this is a milestone for ruby, please speak up if you disagree with this train of thought before I repeatedly reuse it in the future)
v=0
?1.upto($_){p v=v*2|$.^=1}

Try it online!
Explanation
# while gets(); -- assumed by -n
v=0            # First element of the sequence
?1.upto($_){   # Do from "1" to "$LAST_READ_LINE" aka: Repeat [input] times
  p            # print expression
  v=v*2|$.^=1  # Next element is current element times two
               # bitwise-or 0 or 1 alternating
               # $. = lines of input read so far = 1 (initially)
}
# end           -- assumed by -n

Interesting. It's possible in 27 bytes, though.

Nice! Seems that we all got outgolfed by 26b though.

JavaScript (ES7), 39 35 31 30 bytes
1-indexed with output in reverse order.
f=n=>n?[2**n/3|0,...f(--n)]:[]

Try it

o.innerText=(
f=n=>n?[2**n/3|0,...f(--n)]:[]
)(i.value=8);oninput=_=>o.innerText=f(+i.value)
<input id=i type=number>

35 byte version, without recursion
n=>[...Array(n)].map(_=>2**n--/3|0)

o.innerText=(f=
n=>[...Array(n)].map(_=>2**n--/3|0)
)(i.value=8);oninput=_=>o.innerText=f(+i.value)
<input id=i type=number>

Haskell, 52 bytes
(`take`map a[0..])
a 0=0
a 1=1
a n=a(n-1)+2*a(n-2)+1

Try it online!

MATL, 7 bytes
:&+oRXB

Try it online!
Explanation:
         % Implicitly grab input, n
:        % Range: 1 2 ... n

 &+      % Add the range to itself, transposed
         % 2 3 4 5 ...
         % 3 4 5 6 ...
         % 4 5 6 7 ...
         % 5 6 7 8 ...

   o     % Parity (or modulus 2)
         % 0 1 0 1 ...
         % 1 0 1 0 ...
         % 0 1 0 1 ...
         % 1 0 1 0 ...

    R    % Upper triangular matrix:
         % 0 1 0 1
         % 0 0 1 0
         % 0 0 0 1
         % 0 0 0 0

    XB   % Convert rows to decimal:
         % [5, 2, 1, 0]
         % Implicitly output

The output would be 0, 1, 2, 5 ... if P was added to the end (flip), making it 8 bytes.

Good idea, &+

brainfuck, 40 bytes
,[>.>>[>]<[.->[>]+[<]+<]+<[[-<+>]>-<]<-]

Try it online!
0-indexed. Input as char code, output as unary with null bytes separating series of char code 1s. Assumes 8-bit cells unless you want to input over 255. Assumes negative cells, though this could be fixed at the expense of several bytes.
Previously, 50 bytes
,[[<]>->>[<-<->>>>-<]<[->>++<<]>>+[-<<+>>]<<.<<+>]

Try it online!
Inputs as char code, outputs as char code. 1-indexed. Probably could be golfed a little.
@Unihedron points out I forgot to specify that this needs infinite sized cells, otherwise it tops out at the 8th number.

When I run it with `` (0d018) as par the test case, your code prints  *UªUªUªUªUªUª (0x01 02 05 0a 15 2a 55 aa 55 aa 55 aa 55 aa 55 aa 55 aa; 0d001 002 005 010 021 042 085 170 085 170 085 170 085 170 085 170 085 170) :( https://tio.run/##SypKzMxLK03O/v9fJzraJtZO184u2kbXBkjZ2enaxNpEA1na2jZAGTvtaF0bG207u1gbGz0QI/b/fyEA

Ok, seems it is a cell size problem. I think either your code should adapt to big integers or you need to specify the implementation that would run your code properly, but the default of 8-bit cells isn't enough

Forgot about that, thanks @Unihedron! I'll have a think about an 8-bit version, probably outputting in unary.

Using an interpreter with 32-bit cells, it works. Though I think I might have a try at a bitinteger (8bit) version myself if you haven't by the weekend :D

AWK a=0, 31 bytes
{for(;$1--;a=a*2+1-a%2)print a}

Try it online!
Uses the formula shamelessly stolen from this other Ruby answer.
While not having a=0 would work (awk treats "empty" as 0), the first element of 0 won't get printed and instead be an empty line, which while I would argue is a valid output probably won't pass, so there's a=0 which can be inserted as command line argument.

I like your formula ^^

C, 52 bytes
i,k;f(n){for(i=k=0;i<n;k=++i%2+2*k)printf("%d ",k);}

1-indexed
Try it online!

R, 21 bytes
cat(2^(1:scan())%/%3)

Try it online!
Based on the same algorithm as many here. 1-indexed.
R, 37 bytes
for(i in 0:scan())cat(F<-2*F+i%%2,"")

Try it online!
0-indexed. Doubling and adding n mod 2 at each iteration yields the correct result. F is initialized to zero.

Julia 0.6, 15 14 bytes
!n=2.^(1:n)÷3

Try it online!
Using the 2/3 method.
÷ does integer division in Julia and . is element-wise function application.
-1 Byte thanks to Dennis.

÷ doesn't need the ..

I wanted to avoid WARNING: div(A::AbstractArray, B::Number) is deprecated, use div.(A, B) instead..  But you are right: The warning does not matter.

Julia 0.5 doesn't print a warning.

Ruby, 27 bytes
->n{n.times{|i|p 2**i*2/3}}

Try it online!
It's just a Ruby port of this awesome Python answer.

Pyt, 5 bytes
1←ř«₃

Explanation:
1        Pushes 1
 ←       Gets input
  ř      Pushes [1,2,...,input]
   «     Bit-shift 1 to the left by each element in the array
    ₃    Python 2-style division by 3 (2^k/3)

Try it online!

Octave, 20 bytes
@(x)fix(2.^(1:x)./3)

Try it online!
Using @Neils Python method (+1 to him) saves a heck of a lot of bytes.

Previous answer (independent creation):
Octave, 49 40 bytes
@(n)arrayfun(@(x)sum(2.^(x-1:-2:0)),0:n)

Try it online!
Basically for each value x in 0:n where n is the input (0-indexed), we take a range of x-1:-2:0, and raise 2 to the power of each element in the range. The range results in alternating powers of 2, starting with an empty array [] for 0, then [],[1] for 0:1, then [],[1],[1 4] for 0:2, and so on.
If we then sum each of the produced alternating powers of two, we end up with the required sequence. This only works because in Octave the sum of an empty array is 0, so we can produce the first number 0 by producing no powers of two.
The resulting array, which contains all numbers in the pattern up to and including n is then returned.

JavaScript (Node.js), 44 bytes
In ascending order. Simple recursion. 1-indexed.
f=(n,i=0,a=[])=>n?f(n-1,~i&1+i*2,[...a,i]):a

Try it online!
JavaScript (Node.js), 43 41 38 35 bytes
... or return as string. Still in ascending order. 0-indexed.
f=(n,i=0)=>n?i+[,f(n-1,~i&1+i*2)]:i

Try it online!
JavaScript (Node.js), 40 bytes
In ascending order. 2**n/3 trick. 1-indexed.
n=>Array(n).fill(i=0).map(_=>2**++i/3|0)

Try it online!

Ruby, 72 68 61 bytes
->n{a=[0]*n;n.times{|i|i.times{|j|a[i]|=1<<j if i%2!=j%2}};a}

Explained:
def f(n)
  a = [0] * n
  n.times do |i|
    i.times do |j|
      if i.even? != j.even?
        a[i] |= (1 << j)
      end
    end
  end
  a
end

This approach uses n'th bit installation using x | (1 << n). We start from the last bit and proceeding to the first, setting each 2'nd, alternating ones and zeros 'even?' check tells where to start.
Try Now!
I am new in both code golf and Ruby, so any comments will be appreciated!

Welcome to PPCG! Since you're not using f for a recursive call, unnamed functions are completely fine, so you can save two bytes on the f=. Also using odd? instead of even? saves two more bytes.

Pip, 11 bytes
Lai+:i+!%Pi

Attempt This Online!
Explanation
We can compute this sequence without using binary via the following recurrence relation:
\$
a_{n+1} = \left\{
\begin{array}{ll}
     2 a_n + 1 & \text{ if } a_n \text{ even,}  \\
     2 a_n & \text{ if } a_n \text{ odd.}
\end{array}
\right.
\$
Lai+:i+!%Pi
             i (preset to 0) represents the current item in the sequence
 a           First command-line input
L            Loop that many times:
         Pi    Print i
        %      Take i mod 2
       !       Logically negate (1 -> 0 and 0 -> 1)
     i+        Plus current value of i
  i+:          Add that whole expression to i in-place to get next value in sequence

Vyxal, 5 bytes
ʁEd3ḭ

Try it Online!
Port of Neil's Python answer.
How?
ʁEd3ḭ
ʁ     # Exclusive zero range of (implicit) input
 E    # Square, implicit vectorization
  d   # Double, implicit vectorization
   3ḭ # Floor divide by three, implicit vectorization again

Arturo, 18 bytes
$=>[map&=>[/2^&3]]

Try it!
Port of The Thonnu's Thunno 2 answer.

Labyrinth, 22 bytes
1?+:_
 }: 3
 " !/
@({\

Try it online!
Uses the "power of 2 divided by 3" formula.
Intro: 1?
1      Push 1 [1]
?      Input  [1 n]

Loop:  }:+:_3/!\{(  [2^i n-i] -> [2^(i+1) n-(i+1)]
}      Backup top   [2^i | n-i]
:+     Double       [2^(i+1) | n-i]
:      Dup          [2^(i+1) 2^(i+1) | n-i]
_3/    Divide by 3  [2^(i+1) a_(i+1) | n-i]
!\     Print with newline [2^(i+1) | n-i]
{(     Pull and decrement [2^(i+1) n-(i+1)]

Exit:  @ (Halt)

C 52 bytes
i,a;f(n){for(;i++<n;){printf("%d ",a);a=a*2+1-a%2;}}

Try it online!
Without error messages (61 bytes):
int i,a;void f(n){for(;i++<n;){printf("%d ",a);a=a*2+1-a%2;}}

Try it online!

Clean, 61 bytes
import StdEnv
$i=[sum[2^(n-p)\\p<-[1..n]|isOdd p]\\n<-[0..i]]

Try it online!

Python 3 53 bytes
lambda n:[int(('0'+'10'*i)[:i+1],2)for i in range(n)]

Try it online

Red, 71 67 bytes
f: func[n][d: 0 loop n - 1[print d d: d * 2 + either odd? d[0][1]]]

1-indexed
Try it online!
And here's the Red impementation of Neil's 2/3 trick:
Red, 51 bytes
f: func[n][repeat i n[print to-integer 2 ** i / 3]]

Try it online!

SNOBOL4 (CSNOBOL4), 64 bytes
	N =INPUT
I	X =LT(X,N) X + 1	:F(END)
	OUTPUT =2 ^ X / 3	:(I)
END

Try it online!
1-indexed. Uses the 2^i/3 method.

clojure, 61 bytes
(fn f[n r](if(> n 0)(cons r(f(- n 1)(+ r r 1(-(mod r 2)))))))

Usage:
user> (f 10 0)
(0 1 2 5 10 21 42 85 170 341)

Dart, 49 bytes
f(n,{a:0})=>new List.generate(n,(x)=>a=a<<1|x&1);

Use as
main() {
 print(f(31));
}

See DartPad

Jelly, 5 bytes
R2*:3

Try it online!
Took Emigna's strategy and ported it to Jelly.

Scala, 64 bytes
val f=(n:Int)=>Stream from 1 map(i=>(1<<i)/3)take n mkString " "

1-indexed. A call to f(7) for example would return 0 1 2 5 10 21 42.

Perl 5, 44 + 2 (-pa) = 46 bytes
$\+=(length sprintf'%b',$_)/$F[0]while$_--}{

Try it online!

Jelly, 13 bytes
Rṁ@⁾10VDḄ
ḶÇ€

Try it online!

YASEPL, 39 bytes
=n=a'(`1!b$2^n-*/3!s$b(}5,b,2+`2<!+}2,a

explanation:
=n=a'(`1!b$2^n-*/3!s$b(}5,b,2+`2<!+}2,a       packed
=n                                            declare increment
  =a'(                                        get user input and make it integer
      `1                           }2,a       while n < a...
        !b$2^n-*/3                            b = 2*(2^n-1)/3
                  !s$b(                       set s to floor(b)
                       }5,b,2 `2              if s < b...
                             +                then add one to s.
                                <             print s
                                 !+           add one to n


text:
Olympic Rings Sequence
Challenge:
Given an index integer n, either output the n'th item in this sequence, or output the sequence up to and including index n:
25,25,7,28,29,20,21,22,23,14,35,26,7,28,29,20,16,29,12,15,28,21,14,17,30,13,16,29,12,15,28,21,10,6,12,18,15,11,7,13,19,17,13,9,15,21,18,14,10,16,22,19,15,11,17,23,20,16,12,18,24,21,17,13,19,25,23,19,15,21,27,24,20,16,22,28,25,21,17,23,29,16,13,9,15,21,18,14,10,16,22,20,16,12,18,24,21,17,13,19

How does this sequence work?
NOTE: In this explanation, index n is 1-indexed.
Put the numbers 1 through x on two lines of length n*6 - 1, where x depends on the current iteration and the length of the numbers used, and then sum the digits of the n'th/right-most Olympic Rings of those two lines.
The first number in the sequence is calculated as follows:
The length of the lines are 5 (because 1*6 - 1 = 5):
12345
67891(0)

Then leave the digits in an Olympic Rings pattern:
1 3 5
 7 9

And sum them:
1+3+5+7+9 = 25

So n=1 results in 25.
The second number in the sequence is calculated as follows:
The length of the lines are 11 (because 2*6 - 1 = 11):
12345678910
11121314151(6)

Then leave the digits in the second/right-most Olympic Rings pattern:
      7 9 0
       4 5

And sum them:
7+9+0+4+5 = 25

So n=2 results in 25.
The third number in the sequence is calculated as follows:
The length of the lines are 17 (because 3*6 - 1 = 17):
12345678910111213
14151617181920212(2)

Then leave the digits in the third/right-most Olympic Rings pattern:
            1 2 3
             0 1

And sum them:
1+2+3+0+1 = 7

So n=3 results in 7.
etc.
Challenge rules:

When you output the n'th item in the sequence, you are allowed to take the input as 0-indexed instead of 1-indexed, but keep in mind that the calculations of n*6 - 1 will then become (n+1)*6 - 1 or (n+1)*5 + n.
Single numbers of more than one digit can be split up at the end of the first line when we've reached the length n*5 + n-1, so it is possible that a number with 2 or more digits is partially the trailing part of line 1, and partially the leading part of line 2.

General rules:

This is code-golf, so shortest answer in bytes wins.
Don't let code-golf languages discourage you from posting answers with non-codegolfing languages. Try to come up with an as short as possible answer for 'any' programming language.
Standard rules apply for your answer, so you are allowed to use STDIN/STDOUT, functions/method with the proper parameters and return-type, full programs. Your call.
Default Loopholes are forbidden.
If possible, please add a link with a test for your code.
Also, please add an explanation if necessary.

Test cases:
Here is a paste-bin of the test cases 1-1,000, so feel free to choose any of them.
Some additional higher test cases:
1010:   24
1011:   24
2500:   19
5000:   23
7500:   8
10000:  8
100000: 25

1*5 + 1-1 = 5? Shouldn't it be 1*5 + 5 - 1 = 9?

@NieDzejkob No, n=1, so n*5 + n-1 becomes 1*5 + 1-1, which in turn is 5 - 0 = 5.

isn't n * 5 + n - 1 equal to n * 6 - 1?

@BrianH. You're right, it indeed is. Noticed that as well after seeing Martin's Retina answer. I've edited the challenge description to use this shorter formula.

Husk, 16 bytes
ΣĊ2ṁ↑_5↑2CṁdN←*6

Try it online!
-3 bytes thanks to H.PWiz.
(Rushed) explanation:
ΣĊ2ṁ↑_5↑2CṁdN←*6⁰
Σ                 Sum
 Ċ2                Drop every second element
   ṁ↑_5             Map "take last 5 elements", then concatenate
       ↑2            Take first 2 elements
         C            Cut x into sublists of length y
          ṁdN          [1,2,3,4,5,6,7,8,9,1,0,1,1,1,2,1,3,...] (x)
             ←         Decrement (y)
              *6        Multiply with 6
                ⁰        First argument

@KevinCruijssen Weird, because I was just going to add one. However I don't recommend accepting an answer anyway. ;-)

@KevinCruijssen I've added a rushed-up explanation, although it's not very good atm...

Good enough for me, accepted. And personally I prefer to accept challenges, even though it indeed isn't really necessary. If someone happens to post a shorter answer than yours I will of course change it again.

@KevinCruijssen The main objective against that isn't what happens after a shorter answer is posted, but that somebody may be discouraged to post another answer at all. Anyway, your call.

Retina, 70 68 62 bytes
.+
10**
.
$.>`
~(`.+
6*$+*
)`.(.+)
L`.{$.1}
%,-6`.

,2,9`.
*
_

Try it online!
Explanation
Let's call the input n, and we'll use 3 as an example.
.+
10**

The 10** is short for 10*$&*_ which replaces the input with a string of 10n underscores.
.
$.>`

Now we replace each underscore with the length of the string up to and including that underscore. So this just results in the number from 1 to 10n all concatenated together (10n is always enough to fill up two lines of the required length).
~(`.+
6*$+*

Eval! This and the next stage will generate the source code of another program, which is then run against that string of concatenated integers.
To generate that program, this stage first replaces the integers with a string of 6n underscores ($+ refers to the program's original input).
)`.(.+)
L`.{$.1}

Then replace those underscores with L`.{…}, where … is 6n-1 (the length of the lines we're looking at). So we've generated a regex, whose quantifier depends on the original input.
When this program gets eval'ed it matches chunks of length 6n-1, of which there will be at least two. For our example input 3, we end up with:
12345678910111213
14151617181920212
22324252627282930

Now we just need to extract the relevant digits.
%,-6`.

First, on each line (%) we remove all but the last five digits (,-6). That gives us
11213
20212
82930

Finally:
,2,9`.
*

We expand every other digit (2) in the first ten (9, this is 0-based) in unary. Those happen to be those in the Olympic Rings positions.
_

And we count the number of resulting underscores, to sum them and convert the result to decimal.

59 bytes A bit messy though

@H.PWiz Doesn't seem to work for input 1.

Oh yeah, that will be the -7

Japt, 33 32 30 29 28 27 bytes
Oh, this is not pretty!
Outputs the nth term, 1-indexed.
*6É
*2 õ ¬òU mt5n)¬¬ë2 ¯5 x

Try it

Explanation
                         :Implicit input of integer U           :e.g., 3
*6É
*6                       :Input times 6                         :18
  É                      :Subtract 1                            :17
   \n                    :Assign the above to variable U

*2 õ ¬òU mt5n)¬¬ë2 ¯5 x
*2 õ                     :[1,U*2]                               :[1,2,3,...,33,34]
     ¬                   :Join to a string                      :"123...3334"
      òU                 :Partitions of length U                :["123...13","1415...212","22324...30","31323334"]
         m               :Map
          t5n)           :  Get last 5 characters               :["11213","20212","82930","23334"]
              ¬          :Join to a string                      :"11213202128293023334"
               ¬         :Split to an array                     :["1","1","2","1","3","2","0","2","1","2","8","2","9","3","0"],["2","3","3","3","4"]]
                ë2       :Get every second element              :["1","2","3","0","1","8","9","0","3","3"]
                   ¯5    :Get first 5 elements                  :["1","2","3","0","1"]
                      x  :Reduce by addition                    :7
                         :Implicit output of result

Python 2, 94 90 bytes
n=input()*6
s=''.join(map(str,range(n*2)))
print sum(map(int,s[n-5:n:2]+s[n*2-5:n*2-1:2]))

Try it online!

Jelly, 19 bytes
×6’µḤD€Ẏsḣ2ṫ€-4Ẏm2S

Try it online!
×6’µḤD€Ẏsḣ2ṫ€-4Ẏm2S Arguments: n (1-indexed)
×6                  Multiply by 6
  ’                 Decrement
   µ                Call that value N and start a new chain with argument N
    Ḥ               Double
      €             Create an inclusive range from 1 to 2N and call this link on it
     D               Get the decimal digits of each integer in the range
       Ẏ            Concatenate the lists of digits
        s           Split into length-N chunks
         ḣ2         Get the first two elements
            €-4     Map this link over the length-2 list with right argument -4
           ṫ         Get elements from this index onwards (supports negative indices too)
               Ẏ    Concatenate the two length-5 lists into one length-10 list
                m2  Take every second element starting from the first
                  S Sum

Would you mind adding an explanation?

@KevinCruijssen sure, but I usually do it on request, otherwise I focus on answering other challenges, doing other stuff or sleeping :P

Python 3, 129 123 bytes
p=lambda r,x='',i=1:sum(map(int,str(x[6*r-2]+x[6*r-4]+x[6*r-6]+x[12*r-4]+x[12*r-6])))if len(x)>12*r-2else p(r,x+str(i),i+1)

Try It Online
This is pretty much messed up though, but works.

Python 2, 97 bytes
n=input()*6;k=1;s=''
exec's+=`k`;k+=1;'*n*2
print sum(int(s[p])for p in(n-2,n-4,n-6,n*2-4,n*2-6))

Try it online!

05AB1E, 22 21 20 bytes
6*<xLJsô2£íε5£}SāÉÏO

Try it online!
Explanation
6*<                    # push input*6-1
   xL                  # leave it on the stack while pushing [1 ... 12*input-2]
     J                 # join the numbers to a single string
      sô               # split the string into pieces of size input*6-1
        2£             # take the first 2 such pieces
          í            # reverse each string
           ε5£}        # take the first 5 chars of each
               S       # split to a single list of digits
                ā      # push range [1 ... len(list)]
                 ÉÏ    # keep only the numbers in the list of digits which are odd in this
                   O   # sum

Alternative 21 byte approach
6*<©·LJƵYS24S®-ì®-(èO

@KevinCruijssen: Sure. I was intending to try and golf it a bit more before adding the explanation, but I haven't really had time so here it is :)

Thanks! And I know most people prefer to golf it first as much as possible before adding an explanation, but since there hadn't been an update to your answer in 15+ hours I figured I'd just ask for an explanation. :) Nice answer, btw!

J, 61, 58 57 bytes
g=.3 :'+/".,_2(2{.{.)\,_5{."1(2{.(-.6*y)]\;":&.>1+i.9*y)'

Try it online!

Ruby, 65 63 56 bytes
->n{[2,4,6,4-n*=6,6-n].sum{|a|([*1..n*2]*'')[n-a].to_i}}

Try it online!

Clean, 138 101 bytes
import StdEnv
$n=sum(tl[toInt([c-'0'\\i<-[1..],c<-:toString i]!!(6*i+j))\\i<-[2*n-1,n-1],j<-[4,0,2]])

Try it online!

Java 8, 138 111 109 bytes
n->{String s="";int r=0,i=1;for(n=n*6-1;i<3*n;s+=i++);for(i=5;i>0;r+=s.charAt(n+n*(i%2^1)-i--)-48);return r;}

I'll of course have to answer my own challenge. :)
I lost my initial code that I've used to create the test results in the challenge description, so I've just started over.
Explanation:
Try it online.
n->{                               // Method with integer as both parameter and return-type
  String s="";                     //  Temp String
  int r=0,                         //  Result-sum, starting at 0
      i=1;                         //  Index integer, starting at 1
  for(n=n*6-1;                     //  Replace the input with `n*6-1`
      i<3*n;                       //  Loop from 1 up to 3*n (exclusive)
      s+=i++);                     //   And append the temp-String with `i`
  for(i=5;i>0;                     //  Loop from 5 down to 0 (exclusive)
    r+=                            //   Add to the result-sum:
       s.charAt(               )-48);
                                   //    The character at index X, converted to a number,
                n+n*(i%2^1)-i--    //    with X being `n-i` (i=odd) or `n+n-i` (i=even)
  return r;}                       //  Return the result-sum

source: Stack Exchange

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

sort: votes


text:
Compare Two Lists by Their Maximum
Given two different lists of non-negative integers, return the list that has the highest maximum (e.g. [4, 2], [3, 3, 1] -> [4, 2]).
If they both have the same maximum, return the list that contains more instances of this maximum (e.g. [4, 2, 4], [4, 3, 3, 3, 1, 3] -> [4, 2, 4]).
If, after these comparisons, they are equal, do the same comparison but with their next highest item (e.g. [2, 3, 4, 4], [4, 4, 3, 3, 1] -> [4, 4, 3, 3, 1]).
If, after all these comparisons, they are still considered to be equal, output the longer list (e.g. [4, 3, 2, 1, 0], [1, 2, 3, 4] -> [4, 3, 2, 1, 0]).
Make your code as short as possible.
Test Cases
[4, 4, 4, 4, 2, 4], [4, 4, 4, 4, 3, 2] -> [4, 4, 4, 4, 2, 4]
[0], [] -> [0]
[0, 0], [0] -> [0, 0]
[1], [0, 0] -> [1]
[4, 4, 4, 4, 4, 2], [4, 4, 4, 4, 4] -> [4, 4, 4, 4, 4, 2]
[1, 0], [0, 0, 0] -> [1, 0]

Pyth, 4 bytes
eo_S

Try it online
Explanation
eo_S
 o  NQ    Order the inputs...
  _S      ... by their reversed sorted values...
e         ... and take the last.

Python 2, 44 bytes
lambda*x:max(x,key=lambda y:sorted(y)[::-1])

Try it online!

Is this valid for 40 bytes?

No, unfortunately.

Jelly, 4 bytes
NÞÞṪ

Try it online!
How it works
NÞÞṪ  Main link. Argument: [u, v] (pair of vectors)

  Þ   Sort [u, v], using the link to the left as key.
NÞ      Sort u (or v) by the negatives of its values.
        This sorts the vector in descending order.
   Ṫ  Tail; select the last, lexicographically larger vector.

Haskell, 37 35 bytes
import Data.Lists
argmax$sortOn(0-)

The input is taken as a two element list, e.g. ( argmax$sortOn(0-) ) [[4,4,4,4,2,4], [4,4,4,4,3,2]].
Find the element in the input list which is the maximum after sorting by negating the values (i.e. descending order).

Clean, 42 bytes
import StdEnv
s=sortBy(>)
?a b|s a>s b=a=b

Try it online!

Huh, that's an interesting syntax. I take it it means "return a if the pattern guard is true and b otherwise"?

@Laikoni Yep. Pattern guards in Clean are syntactically similar to a C-style if ... else if ..., where you can nest/chain them. And just like you can omit else if(true), you can skip the last guard condition. (however, only once per line)

JavaScript (ES7), 52 bytes
(a,b,m=d=>d.map(n=>N+=1e4**n,N=0)&&N)=>m(a)>m(b)?a:b

This method works without sorting the arrays.  Instead, it calculates the sum of 10,000 raised to each array's elements.  The largest sum represents the array with the highest score.  (This solution assumes that neither array has more than 10,000 elements.)
Test cases

let f=

(a,b,m=d=>d.map(n=>N+=1e4**n,N=0)&&N)=>m(a)>m(b)?a:b

console.log(JSON.stringify(f([4, 4, 4, 4, 2, 4], [4, 4, 4, 4, 3, 2]))); // [4, 4, 4, 4, 2, 4]
console.log(JSON.stringify(f([0], []))); // [0]
console.log(JSON.stringify(f([0, 0], [0]))); // [0, 0]
console.log(JSON.stringify(f([1], [0, 0]))); // [1]
console.log(JSON.stringify(f([4, 4, 4, 4, 4, 2], [4, 4, 4, 4, 4]))); // [4, 4, 4, 4, 4, 2]
console.log(JSON.stringify(f([1, 0], [0, 0, 0]))); // [1, 0]
console.log(JSON.stringify(f([3], [11]))); // [11]
console.log(JSON.stringify(f([4, 3, 3, 3, 1, 3], [4, 2, 4]))); // [4, 2, 4]
console.log(JSON.stringify(f([3,3],[3,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2]))); //[3, 3]

Ruby, 33 bytes
->*a{a.max_by{|x|x.sort.reverse}}

Try it online!

Python 2, 79 bytes
lambda*a:max(a,key=lambda l:sum(zip(map(l.count,s(l)),s(l)),())[::-1])
s=sorted

Try it online!

Ruby 149 bytes
->n,m{(n+m).sort.reverse.map{|i|r=((a=n.index(i))&&m.index(i)?(b=n.count(i))==(c=m.count(i))?nil:b>c ?n:m:a ?n:m);return r if r};n.size>m.size ? n:m}

Try it online!

Husk, 3 bytes
►Ö_

Try it online!
This submission basically takes a two-element list of lists as input and retrieves the maximum (►), sorted by their values sorted in descending order (Ö_).

05AB1E, 5 bytes
Σ{R}θ

Try it online!

JavaScript (ES6), 98 bytes
(a,b,g=a=>[...a].sort((a,b)=>b-a),h=([a,...b],[c,...d])=>a==c?h(b,d):a<c|!(1/a))=>h(g(a),g(b))?b:a

g sorts a copy of its parameter in reverse order (since sort mutates the array), while h recursively performs the elementwise comparison of the arrays.

J, 20 bytes
[:{.]\:[:#.[:>\:~&.>

Ungolfed:
[: {. ] \: [: #. [: > \:~&.>

Essentially the Pyth answer, translated unpithily into J.
Try it online!

Perl 6, 17 bytes
*.max(*.sort(-*))

Test it (Lambda Lambda Lambda)

-* lambda that numerically negates the input
*.sort(-*) lambda that uses that uses the results of applying that to compare elements
*.max(*.sort(-*)) lambda that finds the max of those results, and uses that to determine which input to return.

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


text:
Binary Substrings
Inspired by the fourth problem from BMO2 2009.
Given a positive integer n as input or a parameter, return the number of positive integers whose binary representations occur as blocks in the binary expansion of n.
For example, 13 -> 6 because 13 in binary is 1101 and it has substrings 1101, 110, 101, 11, 10, 1. We do not count binary numbers that start with zero and we do not count zero itself.
Test Cases
13 -> 6
2008 -> 39
63 -> 6
65 -> 7
850 -> 24
459 -> 23
716 -> 22
425 -> 20
327 -> 16

You may take in n as any of the following:

an integer
a list of truthy/falsy values for the binary representation
a string for the binary representation
a base 10 string (though I'm not sure why anyone would do this)

Make your code as short as possible.

Can you confirm 63->5 and not 6? Bin(63)=111111 -> six distinct nonzero substrings

Related. (Uses subsequences instead of substrings and doesn't disregard leading zeros.)

@dylnan Typo. Fixed.

@MartinEnder Is this different enough to stay on this site or shall I delete it as a duplicate? I think it's sufficiently different, but you know a lot better than I do.

@J843136028 The bigger difference for not making it a duplicate is the time restriction on the other challenge. You're fine. (Just posted the link, so that the challenges show up in each other's sidebar.)

Python 3, 54 50 bytes
lambda n:sum(bin(i)[2:]in bin(n)for i in range(n))

Thanks to Rod and Jonathan Allan for saving four bytes.

You can move the +1 from the range to bin(i)

In fact since we always count n itself and are to always exclude 0 from our count we can instead always exclude n and always count 0 (bin(n) starts '0b...'), hence we can remove the 1, and +1 entirely and leave bin(i) as is to save four bytes Try it online!

Jelly, 4 bytes
ẆQSḢ

Try it online!
Takes input as list of 0s and 1s.
Try it online with numbers!
Explanation:
ẆQSḢ Argument: B = list of bits, e.g. [1, 1, 0, 1]
Ẇ    Get B's non-empty sublists (i.e. [[1], [1], [0], [1], [1, 1], [1, 0], [0, 1], [1, 1, 0], [1, 0, 1], [1, 1, 0, 1]])
 Q   Keep first occurrences (i.e. [[1], [0], [1, 1], [1, 0], [0, 1], [1, 1, 0], [1, 0, 1], [1, 1, 0, 1]])
  S  Reduce by vectorized addition (i.e. [6, 4, 1, 1])
   Ḣ Pop first element (i.e. 6)

Proof it works:
This program gets an input number, N. The first thing this product does is, of course, take the substrings of N2 (N in base 2). This includes duplicate substrings starting with either 0 or 1.
After that, we simply take the unique substrings by keeping only the first occurrence of each value in the substring list.
Then, this program sums the first elements of the lists together, then the second elements, then the third, fourth, etc. and if one of the lists has no such element 0 is assumed. What the challenge asks is effectively How many unique substrings starting with 1 does this number have in its binary form?. Since every first element which is to be counted is 1, we can simply sum instead of filtering for appropriate substrings.
Now, the first element of the resulting list of the summation described above holds the count of the first bits of the substrings, so we simply pop and finally return it.

Octave, 62 61  bytes
@(n)sum(arrayfun(@(t)any(strfind((g=@dec2bin)(n),g(t))),1:n))

Try it online!
Explanation
For input n, the code tests all numbers from 1 to n to see if their binary representation is a substring of the binary representation of the input.
@(n)                                                          % Anonymous function of n
        arrayfun(                                      ,1:n)  % Map over range 1:n
                 @(t)                                         % Anonymous function of t
                         strfind(               ,    )        % Indices of ...
                                                 g(t)         % t as binary string ...
                                 (g=@dec2bin)(n)              % within n as binary string
                     any(                             )       % True if contains nonzero
    sum(                                                    ) % Sum of array

05AB1E, 5 bytes
Takes input as a binary string.
The header converts integer input to binary for ease of testing.
ŒCÙĀO

Try it online!
Explanation
Œ        # push all substrings of input
 C       # convert to base-10 int
  Ù      # remove duplicates
   Ā     # truthify (convert non-zero elements to 1)
    O    # sum

Awwhh... I thought my filter was smart. bŒʒć}Ùg but nope, that's better.

Perl 5, 36 + 1 (-p) = 37 bytes
/.*(.+?)(?{$k{0|$1}++})(?!)/;$_=%k-1

Try it online!
Takes input as a binary string.

PowerShell, 103 92 82 bytes
param($s)(($s|%{$i..$s.count|%{-join$s[$i..$_]};$i++}|sort -u)-notmatch'^0').count

Try it online!
Takes input as an array of 1 and 0 (truthy and falsey in PowerShell). Loops through $s (i.e., how many elements in the input array). Inside the loop, we loop from the current number (saved as $i) up to $s.count. Each inner loop, we -join the array slice into a string. We then sort with the -unique flag (which is shorter than select with the -unique flag and we don't care whether they're sorted or not), take those that don't start with 0, and take the overall .count. That's left on the pipeline and output is implicit.

JavaScript (ES6), 55 bytes
f=(s,q="0b"+s)=>q&&s.includes((q--).toString(2))+f(s,q)

Takes input as a binary string.
Here's a sad attempt at doing it with numbers and recursive functions:
f=(n,q=n)=>q&&(g=n=>n?n^q&(h=n=>n&&n|h(n>>1))(q)?g(n>>1):1:0)(n)+f(s,q-1)

Old approach, 74 bytes
s=>(f=s=>+s?new Set([+s,...f(s.slice(1)),...f(s.slice(0,-1))]):[])(s).size

Also takes input as a binary string.

Haskell (126121 bytes)
import Data.List
r o c(t:s)=r([t]:[t:x|x<-o])(o++c)s
r o c[]=o++c
f=length.nub.filter(>"").map(dropWhileEnd(<'1')).r[][]

(5 bytes improvement thanks to @WheatWizard's comment)
Defines a function "f" that accepts a binary string as input.
Ungolfed and commented:
import Data.List -- unfortunately we need some functions that aren't in Prelude

-- recursively generate all sublists of a given list (or string)
-- arguments are the list of sublists currently being worked with,
--   a list of finished sublists, and list to examine
-- output is a list of reversed lists
rsubstrs :: [[t]]->[[t]]->[t]->[[t]]

rsubstrs open closed (t:ts) = rsubstrs ([t]:[t:o|o<-open]) (open++closed) ts
rsubstrs open closed [] = open++closed

-- count unique nonzero binary substrings, produced by composing a sequence of functions:
--   rsubstrs above (with two empty lists supplied to the first two curried arguments)
--   a map operation that removes any trailing sequences of zeros
--   filter to remove empty strings (which were zeros)
--   nub, which finds all unique items in a list
--   length, to count the results
countsubs = length . nub . filter (/="") . map (dropWhileEnd (=='0')) . rsubstrs [] []

Welcome to the site!  Good to have more people golfing in Haskell! Some things pop out immediately in this answer as things that could be improved.  First is that there is no space required before calling a function on a list.  So r [] [] can just be r[][] and you can get rid of another space on the second line the same way.  The other is that both your comparisons (/="") and (=='0') can be written as inequalities a little shorter.  (/="") can always be (>""), because "" is the smallest string, and (=='0') can be written as (<'1') since your inputs can only be 1 or 0.

@WheatWizard - thanks! Annoyingly, those inequality changes are confusing emacs haskell-mode for some reason. :(

Two more things I notice:  (You can ask me to stop trying to help whenever) First is that in Haskell we allow point-free submissions.  The rules are a little confusing but in short, you don't have to count the assignment (f=) on your function because it is point-free.  The other is that [t:x|x<-o] could be map(t:)o which is a bit shorter.  If you want some more tips we have a tips page just for Haskell which is especially good for beginners.

Jelly, 5 bytes
ẆḄQṠS

Try it online!
Takes input as a list of 1s and 0s. The footer in the link applies the function to each of the examples in the post.
Jonathan Allan pointed out that ẆḄQTL is 5 byte alternative which uses the T atom which finds the indices of all truthy elements.
Explanation
Take bin(13)=1101 as an example. Input is [1,1,0,1]
ẆḄQṠS
Ẇ       All contiguous sublists -> 1,1,0,1,11,10,01,110,101,1101 (each is represented as a list)
 Ḅ      From binary to decimal. Vectorizes to each element of the above list -> 1,1,0,1,3,2,1,6,5,13
  Q     Unique elements
   Ṡ    Sign. Positive nums -> 1 , 0 -> 0.
    S   Sum

Took the "truthify" (sign in this case) idea from the 05AB1E answer

You could actually use Jelly's Truthy Indexes atom, T, with ẆḄQTL

R, 88 77 bytes
function(x)sum(!!unique(strtoi(mapply(substring,x,n<-1:nchar(x),list(n)),2)))

Try it online!
Takes input as a binary string.
using mapply, generates an array of all substrings of the input. strtoi converts them as base 2 integers, and I take the sum of the logical conversion (!!) of entries in the result.

Python 2,  118  81 bytes
Thanks to @Rod for saving 37 bytes!
lambda n:len({int(n[i:j+1],2)for i in range(len(n))for j in range(i,len(n))}-{0})

Takes input as a binary string.
Try it online!
Python 2, 81 bytes
Thanks to @Rod!
lambda n:len({n[i:j+1]for i in range(len(n))for j in range(i,len(n))if'1'==n[i]})

Takes input as a binary string.
Try it online!

You can accept a binary string as input, you can also replace set(...) with {...} and xrange with range

You can also move the +1 from the range to the slice, and switch the s.startswith to int(s,2) like this

If you want to keep your old approach, you can also use this for the same byte count

Pyth, 8 bytes
l #{vM.:

Try it here!
Takes input as a binary string.
.: generates all the substrings, vM evaluates each (that is, it converts each from binary), { deduplicates, <space># filters by identity and l gets the length.

Ruby 41 36 27 bytes
Takes binary string as input
Is ultra-inefficient

->n{(?1..n).count{|j|n[j]}}

Partly inspired by this python 3 answer
Try it online!

Retina, 37 29 bytes
.+
*
+`(_+)\1
$1#
#_
_
wp`_.*

Try it online! I just had to try out Retina 1.0's w modifier. Edit: Saved 8 bytes thanks to @MartinEnder. Explanation:
.+
*

Convert from decimal to unary.
+`(_+)\1
$1#
#_
_

Convert from unary to binary, using # for 0 and _ for 1.
wp`_.*

Generate substrings that begin with 1, I mean, _. The w modifier then matches all substrings, not just the longest one at each starting _, while the p modifier deduplicates the matches. Finally as this is the last stage the count of matches is implicitly returned.

You can roll the last three stages into one by using the q (or p) modifier in addition to w. You also don't need to specify C explicitly, because it's the default stage type if there is only a single source left.

@MartinEnder Thanks, I'm still used to M being the default stage type!

Well, C kinda is what M used to be. :)

I know why it's the default, it's just getting used to switching.

Wolfram Language (Mathematica), 35 bytes
Counting unique subsequences of the binary representation that start with one, although I'm not sure this code even needs an explanation.
Union@Subsequences@#~Count~{1,___}&

Try it online!

What does ___ do?

Pattern matching, _ is a single item, __ is one or more, ___ is 0 or more.

Husk, 7 bytes
←LumḋQḋ

Try it online!
Explanation
←LumḋQḋ
      ḋ binary digits of the input
     Q  all possible sublists
   mḋ   convert each back to base-10
  u     uniquify
 L      get the length
←       decrement (since one of the sublists will be 0)

Perl 6, 47 bytes
->\n{+grep {n.base(2).contains(.base: 2)},1..n}

Try it online!

Julia 0.6, 37 bytes
~n=sum(contains.([bin(n)],bin.(1:n)))

Try it online!
Juliafication of the Python answer by J843136028 using . for element-wise function application with broadcasting. (link)

Java, 232 bytes
String b=toBin(n);
l.add(b);
for(int i=1;i<b.length();i++){
for(int j=0;j<=b.length()-i;j++){
String t="";
if((""+b.charAt(j)).equals("0"))continue;
for(int k=0;k<i;k++){
t+=""+b.charAt(j+k);
}
if(!l.contains(t))l.add(t);
}
}
return l.size();

Where n is the input, b is the binary representation and l is a list of all the substrings. First time posting here, definitely need to improve, and feel free to point out any mistakes! Slightly edited for readability.

Welcome to PPCG! Regarding your insertion of newlines for readability, it is  usually preferred to have one scoring version which has exactly the amount of bytes as written in the header, and then an additional ungolfed or less-golfed  version for readability.

@Laikoni Thanks for the heads-up! Will keep in mind for future posts!

String b=...,t and int i=...,j,k to save chars for repeated declarations of the same type. Your code also wouldn't qualify as an entry because it's a snippet, neither a full program nor a functional fragment, you have to write either a function or wrap your code in the lambda form

Attache, 35 bytes
`-&1@`#@Unique@(UnBin=>Subsets@Bin)

Try it online!
Equivalently:
{#Unique[UnBin=>Subsets[Bin[_]]]-1}

Explanation
I will explain the second version, as it is easier to follow (being explicit):
{#Unique[UnBin=>Subsets[Bin[_]]]-1}
{                                 }   lambda: _ = first argument
                        Bin[_]        convert to binary
                Subsets[      ]       all subsets of input
         UnBin=>                      map UnBin over these subsets
  Unique[                      ]      remove all duplicates
 #                              -1    size - 1 (since subsets is improper)

C++, 110 bytes
#include<set>
std::set<int>s;int f(int n){for(int i=1;i<n;i+=i+1)f(n&i);return n?s.insert(n),f(n/2):s.size();}

This is a recursive function.  We use a std::set to count values, ignoring duplicates.  The two recursive calls mask bits off the left (f(n&i)) and off the right (f(n/2)), eventually producing all the substrings as integers.
Note that if you want to call it again, s must be cleared between calls.
Test program
#include <cstdlib>
#include <iostream>

int main(int, char **argv)
{
    while (*++argv) {
        auto const n = std::atoi(*argv);
        s={};
        std::cout << n << " -> " << f(n) << std::endl;
    }
}

Results
./153846 13 2008 63 65 850 459 716 425 327
13 -> 6
2008 -> 39
63 -> 6
65 -> 7
850 -> 24
459 -> 23
716 -> 22
425 -> 20
327 -> 16

Java 8, 160 159 158 bytes
import java.util.*;b->{Set s=new HashSet();for(int l=b.length(),i=0,j;i<l;i++)for(j=l-i;j>0;s.add(new Long(b.substring(i,i+j--))))s.add(0L);return~-s.size();}

Input as binary-String.
There must be a shorter way.. >.>
Explanation:
Try it online.
import java.util.*;          // Required import for Set and HashSet
b->{                         // Method with String as parameter and integer as return-type
  Set s=new HashSet();       //  Create a Set
  for(int l=b.length(),      //  Set `l` to the length of the binary-String
      i=0,j;i<l;i++)         //  Loop from 0 up to `l` (exclusive)
    for(j=l-i;j>0;           //   Inner loop from `l-i` down to `0` (exclusive)
      s.add(new Long(b.substring(i,i+j--))))
                             //    Add every substring converted to number to the Set
      s.add(0L);             //    Add 0 to the Set
  return~-s.size();}         //  Return the amount of items in the Set minus 1 (for the 0)

J, 34 bytes
f=.3 :'<:#~.,(#:i.2^##:y)#.;.1#:y'

Try it online!

J, 15 bytes
#.\\.#@=@-.&,0:

Input is a binary list. Try it online!
#.\\.               Convert every substring to decimal
         -.&,0:     Flatten and remove the 0s.
     #@=            How many unique elements?

Perl 6, 34 bytes
{+unique ~«(.base(2)~~m:ex/1.*/)}

Test it
Expanded:
{
  +                                # turn into Numeric (number of elements)
   unique                          # use only the unique ones
          ~«(                      # turn into strings
             .base(2)              # the input in base 2
                     ~~
                       m:ex/1.*/   # :exhaustive match substrings
                                )
}

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


text:
Code Golf Simulated Golf
Given a list of hole yardages, green sizes, a slice angle and a max distance, compute a golf score.
Assumptions

Earth is flat
All greens are circular
Slice angle will be between -45 and 45 degrees and will be given in degrees
All distances in the same metric (yards or meters, doesn't matter)
No out of bounds, obstructions or doglegs
Max score on any hole is 8
All shots travel the lesser of max distance or distance to the hole, in a direction defined by the angle to the hole plus the slice angle.
Distance is measured as the straight line or Euclidean distance between the start and end point.
Max distance and slice angle are the same for all shots on all holes
The golfer always two-putts once on the green (or exactly on the edge of the green).

Example
Let's look at the hacker from the test case #5 below for hole #2.  The hacker can hit the ball 320 yards, but always slices 30 degrees.  If we assume without loss of generality that the tee box is at {0,0} and the green is at {497,0}, then he will hit shots to the following points, arriving on the green with the 7th shot:
{{0.,0.},{277.128,-160.},{547.543,-131.372},{569.457,7.67088},{502.872,37.2564},{479.159,7.92741},{490.646,-7.85868},{500.078,-4.22987}}
At this point, his score would be 9 due to the two putts required, so the final score for him gets capped at 8, per the assumptions.
Graphically, it will look like this:

Test Cases
All the test cases have standard 18-hole courses
Case#1
{MaxDistance->280,SliceAngle->10,HoleDistances->{181,368,161,416,158,526,377,427,509,148,405,443,510,494,396,388,483,172},GreenDiameters->{26,18,17,23,27,23,21,23,25,21,19,24,21,23,25,24,22,22}}
Scores:
{4,5,4,5,4,5,5,5,5,4,5,5,5,5,5,5,5,4}
Output: 85

Case#2 (same course as Test Case #1, shorter more accurate golfer)
{MaxDistance->180,SliceAngle->5,HoleDistances->{181,368,161,416,158,526,377,427,509,148,405,443,510,494,396,388,483,172},GreenDiameters->{26,18,17,23,27,23,21,23,25,21,19,24,21,23,25,24,22,22}}
Scores:
{4,5,4,5,4,6,5,5,6,4,5,5,6,6,5,5,5,4}
Output: 89

Case#3 (Same golfer as test case #1, shorter course)
{MaxDistance->280,SliceAngle->10,HoleDistances->{147,497,110,528,409,118,196,154,134,514,374,491,131,138,523,478,481,494},GreenDiameters->{32,16,36,25,32,20,30,30,33,29,25,26,26,25,33,28,21,28}}
Scores:
{4,5,4,5,5,4,4,4,4,5,5,5,4,4,5,5,5,5}
Output: 82

Case#4 (Same course as test case #3)
{MaxDistance->180,SliceAngle->5,HoleDistances->{147,497,110,528,409,118,196,154,134,514,374,491,131,138,523,478,481,494},GreenDiameters->{32,16,36,25,32,20,30,30,33,29,25,26,26,25,33,28,21,28}}
Scores:
{3,6,3,6,5,4,4,3,3,5,5,5,3,3,5,5,6,5}
Output: 79

Case#5 (Hacker)
{MaxDistance->320,SliceAngle->30,HoleDistances->{147,497,110,528,409,118,196,154,134,514,374,491,131,138,523,478,481,494},GreenDiameters->{32,16,36,25,32,20,30,30,33,29,25,26,26,25,33,28,21,28}}
Scores:
{6,8,5,8,7,6,6,6,6,8,8,8,6,6,8,8,8,8}
Output: 126

Rules

Any format can be used for the input. Output is simply the number of simulated strokes, so should be an integer.
This is code-golf so the shortest answer in bytes wins.  Standard loopholes apply.

Why is "the Earth is flat" under assumptions?

Can we assume that it will never take more than 6 shots to get the ball to within MaxDistance of the hole?

@JoKing Mainly, so that plane rather than spherical geometry is used; secondly because there was no need to assume spherical chickens :)

@ETHproductions, well you could but that's unnecessary.  I think maybe you mean GreenDiameter/2, in which case yes, since score is capped at 8 and there are always 2 putts.

Don't worry, I worded that question how I meant it ;-) My technique which relies on this doesn't seem to be anywhere near as short as my current answer though, so never mind I guess...

JavaScript (ES7), 128 126 bytes
(m,a,D,S,t=0)=>S.map((s,i)=>t+=(r=(f=d=>d>s/2?1+f((l=d<m?d:m,l*l+d*d-2*d*l*Math.cos(a*Math.PI/180))**.5,s):2)(D[i]))<8?r:8)&&t

Try it online!
Explanation
Because only the distance from the ball to the hole matters and not the coordinates of the ball, we can write an algorithm that calculates how close the ball gets to the hole with each shot, then run that repeatedly until the ball reaches the green. But how do we do this?
Re-using OP's helpful diagram explaining ball movement, with MS Paint modifications:

We have access to these numbers:

d, the current distance from ball to hole;
θ, the slice angle; and
l, the length of the shot (minimum of d and the max shot length).

And the goal is to find x, the distance from ball to hole after the shot is taken.
First we note that a and b are simply l cos θ and l sin θ, respectively. We can see that by the Pythagorean theorem, x can be represented as sqrt(b2 + (d-a)2). Expanding this out, we get
x = sqrt(b^2 + (d - a)^2)
  = sqrt((l*sin(θ))^2 + (d - l*cos(θ))^2)
  = sqrt((l^2 * sin^2(θ)) + (d^2 - 2*d*l*cos(θ) + l^2 * cos^2(θ))
  = sqrt(l^2 * sin^2(θ) + l^2 * cos^2(θ) + d^2 - 2dl*cos(θ))
  = sqrt(l^2 * (sin^2(θ) + cos^2(θ)) + d^2 - 2dl*cos(θ))
  = sqrt(l^2 * 1 + d^2 - 2dl*cos(θ))
  = sqrt(l^2 + d^2 - 2dl*cos(θ))

And so, the new distance from ball to hole will be sqrt(l2 + d2 - 2dl cos θ). Then we count the iterations it takes to get this distance within the radius of the green, add 2, and cap at 8 to get the final score for that hole.
(Thanks to @LegionMammal978 for pointing out that all of the calculations I made are a direct result of the law of cosines...)

Interestingly enough, when the ball is closer to the hole than its max shot, l = d and we can simplify the formula quite a bit further:
x = sqrt(l^2 + d^2 - 2dl*cos(θ))
  = sqrt(d^2 + d^2 - 2d^2*cos(θ))
  = sqrt(2d^2 - 2d^2*cos(θ))
  = sqrt(d^2(2 - 2cos(θ)))
  = d * sqrt(2 - 2cos(θ))

To find the # of remaining iterations, we could then simply find d / r (where r = the radius of the green) and divide that by sqrt(2 - 2cos(θ)), then take the ceiling of the result and add 2. Unfortunately, this doesn't seem to be as short as just finding the smaller of d and the max shot length.

This looks pretty solid.  Could you please post a TIO link when you have a chance?

@KellyLowder Sure, done.

Wouldn't your final equation be a direct consequence of the law of cosines?

@LegionMammal978 I guess it would... Sorry, my trigonometry is a little rusty :P

Do you think you could hard code Math.PI/180 as .0174532925 or shorter depending on how lenient the rules are with floating point precision?

@kamoroso94 That might be a good idea. Using .0174533 gives an error of just 2.38e-7 on the cosine of 45 degrees, so it might be negligible enough to work. Actually now that I look at it, 71/4068 (= 355/113 / 180) is even better, giving an error of just 4.135e-10...

Perl 5, 144 138 + 12 (-MMath::Trig) = 150 bytes
shaved a few bytes using @ETHproductions' simplification of the formula
sub p{$_=pi/180*pop;$m=pop;for$b(@_[0..17]){$s=!++$c;1while++$s<6&&$_[17+$c]/2<($b=sqrt$b*$b+($h=$m<$b?$m:$b)**2-2*$h*$b*cos);$t+=$s+2}$t}

Try it online!
Changed up the input format a bit:
Hole 1 distance
Hole 2 distance
...
Hole 18 distance
Hole 1 green diameter
...
Hole 18 green diameter
Maximum distance
Slice angle

Julia 0.6, 106 bytes
S(m,t,D,G)=(s(m,d,g,v=2)=d<=g/2?v<8?v:8:(l=d<m?d:m;s(l,(d^2+l^2-2d*l*cosd(t))^.5,g,v+1));sum(s.([m],D,G)))

Try it online!
Based on ETHproductions' answer.
Explanation

s(m,d,g,v=2)=... Define function s that calculates the score for one hole recursively.
sum(s.([m],D,G)) Apply s for each hole and sum the result. . is element-wise function application with singleton expansion. E.g.: min.([1],[2,3]) = [min(1,2), min(1,3)]

d<=g/2?v<8?v:8:(l=d<m?d:m;s(...)) #
d<=g/2?       :                   # is the ball on the green?
       v<8?v:8                    # yes -> return min(v,8)
               (l=d<m?d:m;s(...)) # no  ->
                                  # calculate new distance using ETHproductions' formula
                                  # increment current score
                                  # call s recursively


text:
Cyclic Weak Levenquine
This question asking us to make a "Cyclic Levenquine" has gone unanswered. So today we will ask a slightly simpler version.  In this challenge we will define a K-Levenquine to be a program whose output is Levenshtein distance K from its source.
Task
Your goal in this challenge is to write a program with some output different from its own source; running that output as a program should also do the same. Eventually, the sequence of repeatedly running the outputs of each successive program (in the same language) must eventually output the original program.
As with the last challenge there must be two distinct programs in this cycle such that they do not share any two bytes (i.e. their byte sets are disjoint).
As with most quine challenges, reading your own source code is forbidden.
Scoring
Each program in your cycle will be a K-Levenquine for some K.  The largest K of any of the programs in your cycle will be your score.  Your goal should be to minimize this score, with 1 being the optimal score.

Just for clarity, each of the programs should be in the same language, correct?

@FryAmTheEggman yes

Should you make it so that if someone gets to a score of 1, it should be posted on the other question instead? Otherwise, answers could be duplicated if someone gets that far.

Related. Related. Related.

As an example, what is the score of this ouroboros relay-quine? (I assume it is a valid answer to this challenge, if not, explain why not)

@Draco18s not same language

@Christopher2EZ4RTZ Missed the "same language" bit.

Technically I could add my answer from the Mutually exclusive quine question here for a score of 41 right?

@JoKing Yes you could.

Note that because answers from the other question can't be too competitive here (the score is the max of the length) this is not a dupe.

I'll point out that the original challenge carefully specified characters for distance and disjointness, not bytes. In fact in a language where source code has to be valid UTF-8, adding or removing a non-ASCII character in steps of 1 byte is impossible.

@ØrjanJohansen Yes, I made the change from characters to bytes because I am not satisfied that our site wide definition of character is clear.

@user202729 I'll also point out that my question came first, which while not necessarily preventing it from being a dupe target, does help.

You can probably cross out the first line now

Possible duplicate of Cyclic Levenquine

This is an admittedly somewhat bizzare case, but the policy on duplicates is the ability for answers to be copy-pasted while still remaining competitive. Given that any answer from the proposed duplicate target (and that question is answered now) would be a valid and literally unbeatable answer here, the challenges are clearly duplicate in my opinion.

I'm voting to keep this, because this challenge is easier, and the linked potential duplicate has only one answer.

@mbomb007 It doesn't matter that this challenge is easier, since the policy for duplicates is the ability to copy-paste answers from one challenge to another. That one answer to the potential duplicate would be valid and literally unbeatable here, which makes the question a duplicate.

Then perhaps the other question should be closed as a duplicate of this one. I'd prefer just saying that any answer scoring 1 should be posted on the other question and such answers aren't allowed here.

There is now a place to discuss this on meta: https://codegolf.meta.stackexchange.com/questions/17939/closing-a-question-that-asks-a-more-general-question-as-a-duplicate

I'd like to point out that due to the character/byte issue, answers to the old question would not necessarily get perfect score here, if they make use of non-ASCII UTF-8 characters, say for data encoding like in my answer to one of the simpler related challenges. (Partial disclosure: That answer was inspired by my perpetually unfinished design for a real levenquine.)

So, over one month after the applicable meta post was posted, there still has been no change to the duplicate policy to permit generalizations of existing challenges like this one. Even the asker of this challenge has agreed that it is a duplicate under the policy as currently worded. The policy must be enforced, and that means closing this challenge.

I disagree. Consensus hasn't been shown in either direction, and it's due to a lack of activity on the meta question. Post it in 19th byte to get activity. It's not going to hurt anything to leave this challenge open.

><>, Score: 41
'd3*}>a!o-!<<8:5@lI55>@z:5ll55>>q:>|q::|,

and the disjoint program
"r00gr40g44++bb+0p64++?b6+0.22#eW4s )Z

Try it online!
A copy of my answer to the Mutually Exclusive Quine question. A mutually exclusive quine is made of two programs, A and B sharing no common characters, where A outputs B and B outputs A. This means it is a 2-cycle Levenquine and also qualifies for this question. This can act as a baseline for other more inventive answers (though I'm not very confidant this won't go the way of the original Levenquine question).
A more detailed explanation can be found here.

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


text:
Of Dumps and Cubes, and Structured Nonsense
Your challenge is to translate a Cubically cube-dump to the format specified in this challenge.
Input
The input will represent a Rubik's Cube, formatted how Cubically prints its memory cube at the end of every program.
This is a solved cube:
   000
   000
   000
111222333444
111222333444
111222333444
   555
   555
   555

This is a cube scrambled with L2D2L2D2B2R2F2L2D2U2F2UF2U'R2UB2U'L2UB2U'LU'L2U'D'B2U'RBUBF'D' (Singmaster's notation):
   201
   501
   331
132505224540
512324533442
404513210411
   350
   254
   003

Output
If you already understand this format, hit page down a few times to skip lots of explanation.
The output will represent a Rubik's Cube, formatted how solutions to this challenge take input.

The first 12 values are the edge cubies, and the next eight are the corners. The faces are U(p), D(own), R(ight), L(eft), F(ront), and B(ack). First the cubie that's in the UF position is given, by the color (in UFRDBL notation) that's on top first, and then the other color next, and so on.

This format is a bit confusing, so here's a way to visualize it. This is the solved cube:

That renders the output UF UR UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR.
If we were to swap, for example, the red-white edge and the red-blue edge, the visualization would look like this (with no changes to the hidden faces):

That renders the output UR UF UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR (which, btw, is an impossible cube state). Note that the order of the letters in cubies matter:
Above: UR UF UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR
Below: RU FU UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR

The cube scrambled with L2D2L2D2B2R2F2L2D2U2F2UF2U'R2UB2U'L2UB2U'LU'L2U'D'B2U'RBUBF'D' creates this cube (only the top, front, and right faces are shown):

Solved:    UF UR UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR
Scrambled: RU LF UB DR DL BL UL FU BD RF BR FD LDF LBD FUL RFD UFR RDB UBL RBU

As you can see in the comparison above and in the visualizations, the blue-red RU edge of the mixed cube is in the place of the red-white UF edge of the solved cube. The green-white LF edge is in the place of the red-blue UR edge, etc.
Rules

I/O will be done via any allowed means.
The output cubies must be delimited by any whitespace character you choose.
The input will be formatted exactly how it is shown in the challenge, including whitespace.
Your program may do whatever you like if the inputted cube is unsolvable.

Test cases

Input -> output: RU LF UB DR DL BL UL FU BD RF BR FD LDF LBD FUL RFD UFR RDB UBL RBU
Input -> output: UF UR UB UL DF DR DB DL FR FL BR BL UFR URB UBL ULF DRF DFL DLB DBR
Input -> output: FU DL LB BU RU BR RF DR BD DF LF LU FUL FLD URB BLU RUF DBR BDL RFD

Here's a reference program using parts of Cubically's rubiks.c.
Winner
As this is code-golf, the shortest answer in bytes wins!

Sandboxed post and title credit.

Jelly, 87 73 62 61 60 bytes
fØDO“¬ụƘȷ$OkḌ×c¿?oƥ¤_Ọ6;ȤṚUȷ!8⁺⁻:ĠŻ’Œ?¤ịs24Ṗs"2,3ị“LFRBDU”ẎK

Try it online!

Clean, 150 145 143 bytes
Contains many non-printable characters.
import StdEnv
$d=map(\c=['ULFRBD ']!!(digitToInt(['96':d]!!(toInt c))))['!B5J8P;H2)*\'&-,/$ "C76A43O1<Q:9']

Try it online!
Defines the function $, taking [Char], and giving [Char].
This works by mapping each character position in the input to another character position in the output (using the character codes in a string), taking advantage of the swapped 'cubies' in the output being paralleled by swapped colors in the corresponding position in the input.
Output is separated by spaces.

Ruby, 115 bytes
->s{"29&,<&$?&*6&`S&hV&nY&fP&GH&ED&KJ&MB&3:;&%=>&#@5&178&aUT&_RQ&mOZ&oXW".bytes{|i|$><<"   ULFRBD"[s[i-32].ord%9]}}

Try it online!
A function taking the input as an argument and printing to stdout.
Iterate through the long string. Each byte(minus 32) represents the index of the next character to be transcribed.
To transcribe, take the ascii code of the character in the input (012345 or newline) and find the value modulo 9. This gives a number in the range 3 to 8, which is treated as an index in the string "   ULFRBD" to transcribe. Thus the ascii code for 0 is 48, 48%9 is 3, which is the index of U in the string above.
The & signs in the long string point to the first newline in the input (character #10.) This is taken modulo 9 to give the value 1, which is looked up in "   ULFRBD" and transcribed as a space.
The indices in the input are looked up as follows (extra spaces added for clarity)
    #$%
    *+,
    123
567 89: ;<= >?@
BCD EFG HIJ KLM
OPQ RST UVW XYZ
    _`a
    fgh
    mno


text:
Sequentially Divisible
Sometimes to fall asleep, I'll count as high as I can, whilst skipping numbers that are not square-free. I get a little thrill when I get to skip over several numbers in a row - for example, 48,49,50 are all NOT square-free (48 is divisible by 2^2, 49 by 7^2, and 50 by 5^2).
This led me to wondering about the earliest example of adjacent numbers divisible by some arbitrary sequence of divisors.
Input
Input is an ordered list a = [a_0, a_1, ...] of strictly positive integers containing at least 1 element.
Output
Output is the smallest positive integer n with the property that a_0 divides n, a_1 divides n+1, and more generally a_k divides n+k. If no such n exists, the function/program's behavior is not defined.
Test Cases
[15] -> 15
[3,4,5] -> 3
[5,4,3] -> 55
[2,3,5,7] -> 158
[4,9,25,49] -> 29348
[11,7,5,3,2] -> 1518

Scoring
This is code-golf; shortest result (per language) wins bragging rights. The usual loopholes are excluded.

Related.

Wolfram Language (Mathematica), 51 bytes
Mod[ChineseRemainder[1-Range@Length@#,#],LCM@@#,1]&

Try it online!

ChineseRemainder[]? Wow.

Husk, 7 bytes
VδΛ¦⁰ṫN

Try it online!
Explanation
VδΛ¦⁰ṫN  Input is a list x.
      N  The list [1,2,3...
     ṫ   Tails: [[1,2,3...],[2,3,4...],[3,4,5...]...
V        Index of first tail y satisfying this:
  Λ       Every element
    ⁰     of x
   ¦      divides
 δ        the corresponding element of y.

JavaScript, 42 40 bytes
Will throw a recursion error if there is no solution (or the solution is too big).
a=>(g=y=>a.some(x=>y++%x)?g(++n):n)(n=1)

Saved 2 bytes with a pointer from Rick Hitchcock

Try it
Enter a comma separated list of numbers.

o.innerText=(f=
a=>(g=y=>a.some(x=>y++%x)?g(++n):n)(n=1)
)(i.value=[5,4,3]);oninput=_=>o.innerText=f(i.value.split`,`.map(eval))
<input id=i><pre id=o>

Nice approach, but fails by exceeding recursion limits with, e.g., [4,9,25,49].

@ChasBrown, for the purposes of code golf, we may assume infinite memory.

I think this will work for 38 bytes:  (a,y=n=0)=>a.some(x=>y++%x)?f(a,++n):n

Oo, nice one, @RickHitchcock - thanks. Don't forget the f=, though.

Ah, of course.   It's 40 bytes.

MATL, 11 bytes
`Gf@q+G\a}@

Try it online!
`           % Do ....
 Gf         %   Convert input to [1,2,...,]
   @q+      %   Add current iteration index minus one, to get [n, n+1, ....]
      G\    %   Elementwise mod([n,n+1,...],[a_0,a_1,...])
        a   % ...while any of the modular remainders is nonzero.
         }  % Finally:
          @ %   Output the iteration index.

Not exactly optimized for speed... the largest testcase takes a full minute using MATL, and approximately 0.03s on MATLAB. There is a small possibility MATL has a bit more overhead.

ah, I had n:q\QtG\a]1)for 12 bytes butn:is obviously the same asf` here. I always forget about that, so you can add it as an alternative 11 byter.

@Giuseppe Too bad fq`QtG\a}@ returns an extraneous copy of the input.

Python 3, 62 bytes
f=lambda x,n=1:all(j%k<1for j,k in enumerate(x,n))or-~f(x,n+1)

Try it online!

Pyth, 11 bytes
f!s.e%+kTbQ

Try it online!

f!s.e%+kTbQ         Full program - inputs list from stdin and outputs to stdout
f                   First number T such that
   .e     Q         The enumerated mapping over the Input Q
      +kT           by the function (elem_value+T)
     %   b          mod (elem_index)
 !s                 has a false sum, i.e. has all elements 0

Do you need the 2 at the end? I'm sure there's more to be saved here but I don't know Pyth.

@Shaggy and @Giuseppe, both of you are right, and dropping the ending 2 fixes the issue

Clean, 61 bytes
import StdEnv
$l=hd[n\\n<-[1..]|and[i/e*e==i\\i<-[n..]&e<-l]]

Try it online!

I think you need [1..] instead of [0..] to avoid outputting 0, a non-positive integer, for singleton lists.

@Laikoni thanks, fixed.

Haskell, 45 44 bytes
f a=[n|n<-[1..],1>sum(zipWith mod[n..]a)]!!0

Try it online!
Edit: -1 byte thanks to nimi!

sum(zipWith mod[n..]a)<1.

05AB1E, 9 bytes
Xµā<N+sÖP

Try it online!
Explanation
Xµ          # loop until counter equals 1
  ā         # push range [1 ... len(input)]
   <        # decrement
    N+      # add current iteration index N (starts at 1)
      sÖ    # elementwise evenly divisible by
        P   # product
            # if true, increase counter
            # output N

Demolishes my 17 byte answer, ouch.

J, 23 bytes
[:I.0=]+/@:|"1#]\[:i.*/

Try it online!

Nice.  What's the mathematical fact that allows you to only check up to the product of the inputs?  How do we know there can't be a solution beyond that?  Also, how do we know I. will only return 1 result?  Isn't it possible there are multiple?

@Jonah - I don't know if it works always; just all the tests I did were in these limits.

R, 51 bytes
function(l){while(any((F+1:sum(l|1))%%l))F=F+1
F+1}

Try it online!
The use of any throws k warnings about implicit conversion to logical, where k is the return value.

47 bytes!

@plannapus I considered that but it unfortunately fails for l=c(15), since seq(l)==1:l in that case. seq is annoying like that!

arf indeed and then forcing seq_along is just too long.

So, but using sum instead of any get rid of those warnings, FYI.

APL (Dyalog Unicode), 24 23 22 bytes
{∨/×⍺|⍵+⍳⍴⍺:⍺∇⍵+1⋄⍵}∘1

Try it online!
Technically, this is a tacit function. I had to make it so since the only input allowed is the list of integers. Uses ⎕IO←0 (0-indexing)
It's worth noting that the function times out if n doesn't exist.
Thanks to @ngn and @H.PWiz for 1 byte each.
How?
{∨/×⍺|⍵+⍳≢⍺:⍺∇⍵+1⋄⍵}∘1 ⍝ Main function. ⍺=input; ⍵=1.
{                   }∘1 ⍝ Using 1 as right argument and input as left argument:
           :            ⍝ If
        ⍳≢⍺             ⍝ The range [0..length(⍺)]
      ⍵+                ⍝ +⍵ (this generates the vector ⍵+0, ⍵+1,..., ⍵+length(⍺))
    ⍺|                  ⍝ Modulo ⍺
   ×                    ⍝ Signum; returns 1 for positive integers, ¯1 for negative and 0 for 0.
 ∨/                     ⍝ Logical OR reduction. Yields falsy iff the elements of the previous vector are all falsy.
            ⍺∇⍵+1       ⍝ Call the function recursively with ⍵+1.
                 ⋄⍵     ⍝ Else return ⍵.

Perl 6, 34 bytes
->\a{first {all ($_..*)Z%%a},^∞}

Try it online!

30 bytes

Perl 5, 49 + 2 (-pa) = 51 bytes
$i=!++$\;($\+$i)%$_&&last,$i++for@F;$i<@F&&redo}{

Try it online!

Japt, 10 bytes
Will eventually output undefined if no solution exists, if it doesn't crash your browser first.
@e_X°vZÃ}a

Try it

Explanation
               :Implicit input of array U
@       }a     :Loop and output the first integer X that returns true.
 e_    Ã       :For every element Z in U
   X°          :X, postfix increcemnted
     vZ        :Is it divisible by Z?

Ruby, 48 bytes
->l{1+(1..1/0.0).find{|x|l.all?{|y|(x+=1)%y<1}}}

Try it online!

Python 2, 80 bytes
def f(l,n=1):
 while n:
	n+=1
	if all((n+i)%v<1for i,v in enumerate(l)):return n

Try it online!

Ruby, 47 46 43 42 bytes
->a{(1..).find{|i|a.all?{|v|i%v<1&&i+=1}}}

Try it online!
NB: the (1..) syntax is only supported in ruby 2.6, for the moment TIO only supports 2.5 so the link is to an older version (43 bytes).

PowerShell, 65 62 bytes
for(){$o=1;$i=++$j;$args[0]|%{$o*=!($i++%$_)};if($o){$j;exit}}

Try it online!
PowerShell doesn't have the equivalent of an any or some or the like, so we need a slightly different approach.
This takes input $args[0] as an array, then enters an infinite for loop. Each iteration we set $o to be 1 (explained later), and set $i to be ++$j. The incrementing $j keeps tabs on what the first number of the proposed solution is, while the $i will increment over the rest of the proposed solution.
We then send each element of the input $args[0] into a ForEach-Object loop. Inside the inner loop, we Boolean-multiply into $o the result of a calculation. This will make it so that if the calculation fails for a value, the $o will turn to 0. The calculation is !($i++%$_), or the Boolean-not of the modulo operation. Since any nonzero value is truthy in PowerShell, this turns any remainders into a falsey value, thus turning $o into 0.
Outside the inner loop, if $o is nonzero, we've found an incrementing solution that works, so we output $j and exit.

Standard ML (MLton), 96 bytes
open List;fun$n% =if all hd(tabulate(length%,fn i=>[1>(n+i)mod nth(%,i)]))then n else$(n+1)%;$1;

Try it online!
Ungolfed:
open List
fun f n l =
    if all (fn x=>x)
           (tabulate ( length l
                     , fn i => (n+i) mod nth(l,i) = 0))
    then n
    else f (n+1) l
val g = f 1

Try it online! Starting with n=1, the function f increments n until the all-condition is fulfilled, in which case n is returned.
tabulate(m,g) with some integer m and function g builds the list [g 0, g 1, ..., g m]. In our condition tabulate is called with the length of the input list l and a function which checks whether the ith element of l divides n+i. This yields a list of booleans, so all with the identity function fn x=>x checks whether all elements are true.
I found a nice golfing trick to shorten the identity function in this case by four bytes: Instead of the lambda (fn x=>x), the build-in function hd is used, which returns the first element of a list, and the resulting bools in tabulate are wrapped in [ and ] to create singleton lists.

tinylisp, 108 bytes
(load library
(d ?(q((L N)(i L(i(mod N(h L))0(?(t L)(inc N)))1
(d S(q((L N)(i(? L N)N(S L(inc N
(q((L)(S L 1

The last line is an unnamed lambda function that takes a list and returns an integer. Try it online!
Ungolfed
(load library)

(comment Function to check a candidate n)
(def sequentially-divisible?
 (lambda (divisors start-num)
  (if divisors
   (if (divides? (head divisors) start-num)
    (sequentially-divisible? (tail divisors) (inc start-num))
    0)
   1)))

(comment Function to check successive candidates for n until one works)
(def search
 (lambda (divisors start-num)
  (if (sequentially-divisible? divisors start-num)
   start-num
   (search divisors (inc start-num)))))

(comment Solution function: search for candidates for n starting from 1)
(def f
 (lambda (divisors)
  (search divisors 1)))

Python 2, 78 bytes
def f(a,c=0):
 while [j for i,j in enumerate(a) if(c+i)%j<1]!=a:c+=1
 return c

EDIT: -26 thanks to @Chas Brown

Nice! I turned your loop exit condition around, and your idea can be improved upon to get 78 bytes .

@ChasBrown thanks, I didn't think of doing it that way. Changed!

Julia 0.6, 79 bytes
f(s,l=length(s),n=s[])=(while !all(mod.(collect(0:l-1).+n,s).==0);n+=s[];end;n)

Try it online!
Inputs without valid solutiosn will cause infinite looping... :)

Java 8, 82 75 bytes
a->{for(int r=1,i,f;;r++){i=f=0;for(int b:a)f+=(r+i++)%b;if(f<1)return r;}}

Explanation:
Try it online.
a->{                 // Method with integer-array parameter and integer return-type
  for(int r=1,       //  Return-integer, starting at 1
          i,         //  Index-integer
          f;         //  Flag-integer
      ;r++){         //  Loop indefinitely, increasing `r` by 1 after every iteration
    i=f=0;           //   Reset both `i` and `f` to 0
    for(int b:a)     //   Inner loop over the input-array
      f+=(r+i++)%b;  //    Increase the flag-integer by `r+i` modulo the current item
    if(f<1)          //   If the flag-integer is still 0 at the end of the inner loop
      return r;}}    //    Return `r` as result

Jelly, 10 bytes
1Ḷ+$ọ¥Ạ¥1#

Try it online!

APL NARS, 140 bytes, 70 chars
r←f w;i;k
i←r←1⊃,w⋄k←¯1+⍴w⋄→0×⍳k=0
A:→0×⍳0=+/(1↓w)∣(k⍴r)+⍳k⋄r+←i⋄→A

test
  f 15
15
  f 3 4 5
3
  f 5 4 3
55
  f 2 3 5 7
158
  f 4 9 25 49
29348
  f 11 7 5 3 2
1518