Answer: Yes, for both parts.
Fix some odd prime p, and let T be the smallest positive integer such that p∣2T−1; in other words T is the multiplicative order of 2 modulo p.
Consider any p-sequence (xn)=(x0,x1,x2,…). Obviously, xn+1≡2xn(modp) and therefore xn≡2nx0(modp). This yields xn+T≡xn(modp) and therefore d(xn+T)=d(xn) for all n≥0. It follows that the sum d(xn)+d(xn+1)+⋯+d(xn+T−1) does not depend on n and is thus a function of x0 and p only; we shall denote this sum by Sp(x0), and extend the function Sp(⋅) to all (not necessarily positive) integers. Therefore, we have xn+kT=xn+kSp(x0) for all positive integers n and k. Clearly, Sp(x0)=Sp(2tx0) for every integer t≥0.
In both parts, we use the notation
Sp+=Sp(1)=i=0∑T−1dp(2i) and Sp−=Sp(−1)=i=0∑T−1dp(p−2i)
a.
Let q>3 be a prime and p a prime divisor of 2q+1 that is greater than 3. We will show that p is suitable for part (a). Notice that 9∤2q+1, so that such a p exists. Moreover, for any two odd primes q<r we have gcd(2q+1,2r+1)=2gcd(q,r)+1=3, thus there exist infinitely many such primes p.
For the chosen p, we have T=2q. Since 2q≡−1(modp), we have Sp+=Sp−. Now consider the p-sequences (an) and (bn) with a0=p+1 and b0=p−1; we claim that these sequences satisfy the required conditions. We have a0>b0 and
ak⋅2q=a0+kSp+>b0+kSp+=bk⋅2q and ak⋅2q+1=a1+kSp+<b1+kSp+=bk⋅2q+1
for all k=0,1,…, as desired.
b.
Let q be an odd prime and p a prime divisor of 2q−1; thus we have T=q. We will show that p is suitable for part (b). Notice that the numbers of the form 2q−1 are pairwise coprime (since gcd(2q−1,2r−1)=2gcd(q,r)−1=1 for any two distinct primes q and r), thus there exist infinitely many such primes p. Notice that dp(x)+dp(p−x)=p for all x with p∤x, so that the sum Sp++Sp−=pq is odd, which yields Sp+=Sp(1)=Sp(−1)=Sp−. Assume that (xn) and (yn) are two p-sequences with Sp(x0)>Sp(y0) but x0<y0. The first condition yields that
xMq+r−yMq+r=(xr−yr)+M(Sp(x0)−Sp(y0))≥(xr−yr)+M
for all nonnegative integers M and every r=0,1,…,q−1. Thus, we have xn>yn for every n≥q+q⋅max{yr−xr:r=0,1,…,q−1}. Now, since x0<y0, there exists the target n0 with xn0<yn0. In this case the p-sequences an=xn−n0 and bn=yn−n0 possess the desired property (notice here that xn=yn for all n≥0, as otherwise we would have Sp(x0)=Sp(xn)=Sp(yn)=Sp(y0)).
It remains to find p-sequences (xn) and (yn) satisfying the two conditions. Recall that Sp+=Sp−. Now if Sp+>Sp−, then we can put x0=1 and y0=p−1. Otherwise, if Sp+<Sp−, then we put x0=p−1 and y0=p+1.