Problem p03104 (python)

Fixed submission:
#121-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
a,b=IL()
import math
if a==0:
    if b==0:
        n=1
    else:
        n=int(math.log(b,2))+1
else:
    if b==0:
        n=int(math.log(a,2))+1
    else:
        n=max(int(math.log(a,2)),int(math.log(b,2)))+1
al=[0 for i in range(n)]
bl=[0 for i in range(n)]
cl=[0 for i in range(n)]
for i in range(1,n):
    k=pow(2,i+1)
    al[i]=a%k
    bl[i]=b%k
    bou=k//2-1
    if al[i]<=bl[i]:
        if al[i]<=bou:
            if bl[i]<=bou:
                cl[i]=0
            else:
                cl[i]=0 if (bl[i]-bou)%2==0 else 1
        else:
            cl[i]=1 if (bl[i]-al[i])%2==0 else 0
    else:
        if bl[i]<=bou:
            if al[i]<=bou:
                cl[i]=0
            else:
                cl[i]=0 if (k-al[i])%2==0 else 1
        else:
            if al[i]<=bou:
                cl[i]=0 if (bl[i]-bou)%2==0 else 1
            else:
                cl[i]=0 if (k-al[i]+bl[i]-bou)%2==0 else 1
if a%2==0:
    if b%2==0:
        cl[0]=0 if ((b-a)//2)%2==0 else 1
    else:
        cl[0]=0 if (((b+1)-a)//2)%2==0 else 1
else:
    if b%2==1:
        cl[0]=1 if ((b-a)//2)%2==0 else 0
    else:
        cl[0]=1 if (((b-1)-a)//2)%2==0 else 0
        
ans=0
for i in range(n):
    ans+=cl[i]*pow(2,i)
print(ans)

Buggy submission (verdict: Runtime Error):
#121-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
a,b=IL()
import math
if a==0:
    if b==0:
        n=0
    else:
        n=int(math.log(b,2))+1
else:
    if b==0:
        n=int(math.log(a,2))+1
    else:
        n=max(int(math.log(a,2)),int(math.log(b,2)))+1
al=[0 for i in range(n)]
bl=[0 for i in range(n)]
cl=[0 for i in range(n)]
for i in range(1,n):
    k=pow(2,i+1)
    al[i]=a%k
    bl[i]=b%k
    bou=k//2-1
    if al[i]<=bl[i]:
        if al[i]<=bou:
            if bl[i]<=bou:
                cl[i]=0
            else:
                cl[i]=0 if (bl[i]-bou)%2==0 else 1
        else:
            cl[i]=1 if (bl[i]-al[i])%2==0 else 0
    else:
        if bl[i]<=bou:
            if al[i]<=bou:
                cl[i]=0
            else:
                cl[i]=0 if (k-al[i])%2==0 else 1
        else:
            if al[i]<=bou:
                cl[i]=0 if (bl[i]-bou)%2==0 else 1
            else:
                cl[i]=0 if (k-al[i]+bl[i]-bou)%2==0 else 1
if a%2==0:
    if b%2==0:
        cl[0]=0 if ((b-a)//2)%2==0 else 1
    else:
        cl[0]=0 if (((b+1)-a)//2)%2==0 else 1
else:
    if b%2==1:
        cl[0]=1 if ((b-a)//2)%2==0 else 0
    else:
        cl[0]=1 if (((b-1)-a)//2)%2==0 else 0
        
ans=0
for i in range(n):
    ans+=cl[i]*pow(2,i)
print(ans)

Buggy submission (verdict: Runtime Error):
#121-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
a,b=IL()
import math
n=max(int(math.log(a,2)),int(math.log(b,2)))+1
al=[0 for i in range(n)]
bl=[0 for i in range(n)]
cl=[0 for i in range(n)]
for i in range(1,n):
    k=pow(2,i+1)
    al[i]=a%k
    bl[i]=b%k
    bou=k//2-1
    if al[i]<=bl[i]:
        if al[i]<=bou:
            if bl[i]<=bou:
                cl[i]=0
            else:
                cl[i]=0 if (bl[i]-bou)%2==0 else 1
        else:
            cl[i]=1 if (bl[i]-al[i])%2==0 else 0
    else:
        if bl[i]<=bou:
            if al[i]<=bou:
                cl[i]=0
            else:
                cl[i]=0 if (k-al[i])%2==0 else 1
        else:
            if al[i]<=bou:
                cl[i]=0 if (bl[i]-bou)%2==0 else 1
            else:
                cl[i]=0 if (k-al[i]+bl[i]-bou)%2==0 else 1
if a%2==0:
    if b%2==0:
        cl[0]=0 if ((b-a)//2)%2==0 else 1
    else:
        cl[0]=0 if (((b+1)-a)//2)%2==0 else 1
else:
    if b%2==1:
        cl[0]=1 if ((b-a)//2)%2==0 else 0
    else:
        cl[0]=1 if (((b-1)-a)//2)%2==0 else 0
        
ans=0
for i in range(n):
    ans+=cl[i]*pow(2,i)
print(ans)

Buggy submission (verdict: Runtime Error):
#121-D
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
a,b=IL()
import math
n=max(int(math.log(a,2)),int(math.log(b,2)))+1
al=[0 for i in range(n)]
bl=[0 for i in range(n)]
cl=[0 for i in range(n)]
for i in range(1,n):
    k=pow(2,i+1)
    al[i]=a%k
    bl[i]=b%k
    bou=k//2-1
    if al[i]<=bl[i]:
        if al[i]<=bou:
            if bl[i]<=bou:
                cl[i]=0
            else:
                cl[i]=0 if (bl[i]-bou)%2==0 else 1
        else:
            cl[i]=1 if (bl[i]-al[i])%2==0 else 0
    else:
        if bl[i]<=bou:
            if al[i]<=bou:
                cl[i]=0
            else:
                cl[i]=0 if (k-al[i])%2==0 else 1
        else:
            if al[i]<=bou:
                cl[i]=0 if (bl[i]-bou)%2==0 else 1
            else:
                cl[i]=0 if (k-al[i]+bl[i]-bou)%2==0 else 1
if a%2==0:
    if b%2==0:
        cl[0]=0 if ((b-a)//2)%2==0 else 1
    else:
        cl[0]=0 if (((b+1)-a)//2)%2==0 else 1
else:
    if b%2==1:
        cl[0]=1 if ((b-a)//2)%2==0 else 0
    else:
        cl[0]=1 if (((b-1)-a)//2)%2==0 else 0
        
ans=0
for i in range(n):
    ans+=cl[i]*pow(2,i)
print(ans)