Problem p03331 (python)

Fixed submission:
N = int(input())
c_list = []
if N % 2 ==0:
    for i in range(1, int((N+2)/2)):
        A = i
        a1 = A//10**5
        a2 = (A - 10**5*a1)//10**4
        a3 = (A-10**5*a1-10**4*a2)//10**3
        a4 = (A-10**5*a1-10**4*a2-10**3*a3)//10**2
        a5 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4)//10
        a6 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4-10*a5)
        B = N - i
        b1 = B//10**5
        b2 = (B - 10**5*b1)//10**4
        b3 = (B-10**5*b1-10**4*b2)//10**3
        b4 = (B-10**5*b1-10**4*b2-10**3*b3)//10**2
        b5 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4)//10
        b6 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4-10*b5)
        C = a1+a2+a3+a4+a5+a6+b1+b2+b3+b4+b5+b6
        c_list.append(C)
else:
    for i in range(1, int((N+1)/2)):
        A = i
        a1 = A//10**5
        a2 = (A - 10**5*a1)//10**4
        a3 = (A-10**5*a1-10**4*a2)//10**3
        a4 = (A-10**5*a1-10**4*a2-10**3*a3)//10**2
        a5 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4)//10
        a6 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4-10*a5)
        B = N - i
        b1 = B//10**5
        b2 = (B - 10**5*b1)//10**4
        b3 = (B-10**5*b1-10**4*b2)//10**3
        b4 = (B-10**5*b1-10**4*b2-10**3*b3)//10**2
        b5 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4)//10
        b6 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4-10*b5)
        C = a1+a2+a3+a4+a5+a6+b1+b2+b3+b4+b5+b6
        c_list.append(C)
print(min(c_list))

Buggy submission (verdict: Runtime Error):
N = int(input())
c_list = []
if N % 2 ==0:
    for i in range(1, int(N/2)):
        A = i
        a1 = A//10**5
        a2 = (A - 10**5*a1)//10**4
        a3 = (A-10**5*a1-10**4*a2)//10**3
        a4 = (A-10**5*a1-10**4*a2-10**3*a3)//10**2
        a5 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4)//10
        a6 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4-10*a5)
        B = N - i
        b1 = B//10**5
        b2 = (B - 10**5*b1)//10**4
        b3 = (B-10**5*b1-10**4*b2)//10**3
        b4 = (B-10**5*b1-10**4*b2-10**3*b3)//10**2
        b5 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4)//10
        b6 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4-10*b5)
        C = a1+a2+a3+a4+a5+a6+b1+b2+b3+b4+b5+b6
        c_list.append(C)
else:
    for i in range(1, int((N+1)/2)):
        A = i
        a1 = A//10**5
        a2 = (A - 10**5*a1)//10**4
        a3 = (A-10**5*a1-10**4*a2)//10**3
        a4 = (A-10**5*a1-10**4*a2-10**3*a3)//10**2
        a5 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4)//10
        a6 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4-10*a5)
        B = N - i
        b1 = B//10**5
        b2 = (B - 10**5*b1)//10**4
        b3 = (B-10**5*b1-10**4*b2)//10**3
        b4 = (B-10**5*b1-10**4*b2-10**3*b3)//10**2
        b5 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4)//10
        b6 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4-10*b5)
        C = a1+a2+a3+a4+a5+a6+b1+b2+b3+b4+b5+b6
        c_list.append(C)
print(min(c_list))

Buggy submission (verdict: Runtime Error):
N = int(input())
c_list = []
if N % 2 ==0:
    for i in range(1, int(N/2)):
        A = i
        a1 = A//10**5
        a2 = (A - 10**5*a1)//10**4
        a3 = (A-10**5*a1-10**4*a2)//10**3
        a4 = (A-10**5*a1-10**4*a2-10**3*a3)//10**2
        a5 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4)//10
        a6 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4-10*a5)
        B = N - i
        b1 = B//10**5
        b2 = (B - 10**5*b1)//10**4
        b3 = (B-10**5*b1-10**4*b2)//10**3
        b4 = (B-10**5*b1-10**4*b2-10**3*b3)//10**2
        b5 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4)//10
        b6 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4-10*b5)
        C = a1+a2+a3+a4+a5+a6+b1+b2+b3+b4+b5+b6
        c_list.append(C)
else:
    for i in range(1, int((N-1)/2)):
        A = i
        a1 = A//10**5
        a2 = (A - 10**5*a1)//10**4
        a3 = (A-10**5*a1-10**4*a2)//10**3
        a4 = (A-10**5*a1-10**4*a2-10**3*a3)//10**2
        a5 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4)//10
        a6 = (A-10**5*a1-10**4*a2-10**3*a3-10**2*a4-10*a5)
        B = N - i
        b1 = B//10**5
        b2 = (B - 10**5*b1)//10**4
        b3 = (B-10**5*b1-10**4*b2)//10**3
        b4 = (B-10**5*b1-10**4*b2-10**3*b3)//10**2
        b5 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4)//10
        b6 = (B-10**5*b1-10**4*b2-10**3*b3-10**2*b4-10*b5)
        C = a1+a2+a3+a4+a5+a6+b1+b2+b3+b4+b5+b6
        c_list.append(C)
print(min(c_list))