Let $a(n)$ be A057985 (i.e., start with $0$ and repeatedly substitute: $0 \to 01$, $1 \to 12$, $2 \to 0$).
Let $b(n)$ be A287066 (i.e., start with $1$ and repeatedly substitute: $0 \to 01$, $1 \to 12$, $2 \to 0$).
Let $c(n)$ be A005314. Here
$$ c(n) = 2c(n-1) - c(n-2) + c(n-3), \\ c(0) = 0, c(1) = 1, c(2) = 2 $$
- Let $d(n)$ be an integer sequence such that
$$ d(n) = \sum\limits_{i=1}^{n} c(i) $$
Let $e(n)$ be the smallest number $k$ such that $c(k)>n$.
Let $f(n)$ be the smallest number $q$ such that $d(q)>n$.
I conjecture that
$$ a(n) = b(n - d(f(n-2) - 1) - 1), \\ a(1) = 0, a(2) = 1, \\ b(n) = a(n - c(e(n-1) - 1)), \\ b(1) = 1, b(2) = 2 $$
Here is the PARI/GP program to check it numerically:
a_upto(n) = my(A = 2, B = 2, v1); v1 = vector(n+1, i, 0); v1[2] = 1; while(B<n, if(v1[A]==2, v1[B+1] = 0, v1[B+1] = v1[A]; v1[B+2] = v1[A] + 1; B++); A++; B++); v1 = vector(n, i, v1[i])
b_upto(n) = my(A = 2, B = 2, v1); v1 = vector(n+1, i, 0); v1[1] = 1; v1[2] = 2; while(B<n, if(v1[A]==2, v1[B+1] = 0, v1[B+1] = v1[A]; v1[B+2] = v1[A] + 1; B++); A++; B++); v1 = vector(n, i, v1[i])
f1(n) = if(n == 1, 2, my(A = solve(r=0, 1, r*(2 - r + r^2)-1)); ceil(log((19*A - A^2 + 11*A^3)/(23*n))/log(A)))
f2(n) = my(A = f1(n) + 1, v1); v1 = vector(A, i, 0); v1[2] = 1; v1[3] = 2; for(i = 4, A, v1[i] = 2*v1[i-1] - v1[i-2] + v1[i-3]); while(!(v1[A] > n), v1 = concat(v1, 2*v1[A] - v1[A-1] + v1[A-2]); A++); v2 = v1; for(i = 2, A, v2[i] += v2[i-1]); [v1, v2]
a1(n) = my(v1, v2); v1 = f2(n); v2 = v1[2]; v1 = v1[1]; my(A = #v1, B = A, C = 0); while(n > 2, if(!(C%2), while(v2[A] > (n-2), A--); n -= v2[A] + 1, while(v1[B] > (n-1), B--); n -= v1[B]); C++); n + C%2 - 1
b1(n) = my(v1, v2); v1 = f2(n); v2 = v1[2]; v1 = v1[1]; my(A = #v1, B = A, C = 0); while(n > 2, if(C%2, while(v2[A] > (n-2), A--); n -= v2[A] + 1, while(v1[B] > (n-1), B--); n -= v1[B]); C++); n - C%2
test1(n) = vector(n, i, a1(i)) == a_upto(n)
test2(n) = vector(n, i, b1(i)) == b_upto(n)
Is there a way to prove it?