Problem p02659 (python)

Fixed submission:
A, B = map(str, input().split())
 
B = str(int(float(B)*100+0.00001))
 
#print(B)
ans = []
p = [[]for k in range(len(B))]
for k in range(len(B)):
    for j in range(k):
        p[k].append(0)
for k in range(1, len(B)+1):
    a = 0
    for j in range(1, len(A)+1):
        if a > 9:
            a = int(str(a)[0]) + int(B[-k])*int(A[-j])
        else:
            a = int(B[-k])*int(A[-j])
        #print(a)
 
        p[k-1].append(int(str(a)[-1]))
        if j == len(A) and a >9:
            p[k-1].append(int(str(a)[0]))
 
for k in range(len(B)):
    for j in range(len(p[-1]) - len(p[k])):
        p[k].append(0)
 
#print(p)
a = 0
for k in range(len(p[0])): 
    if int(a) > 9: 
        a = int(str(a)[0])
    else:
        a =0
    for j in range(len(p)):
        a += p[j][k]
    ans.append(str(a)[-1])
    if k ==  len(p[0])-1 and a >9:
        ans.append(str(a)[0])

 
#print(ans)
op = ""
for k in range(1, len(ans)-1):
    op += ans[-k]
if len(ans)<3 or int(op) < 1:
    print("0")
else:
    print(op)

Buggy submission (verdict: Runtime Error):
A, B = map(str, input().split())
 
B = str(int(float(B)*100+0.00001))
 
#print(B)
ans = []
p = [[]for k in range(len(B))]
for k in range(len(B)):
    for j in range(k):
        p[k].append(0)
for k in range(1, len(B)+1):
    a = 0
    for j in range(1, len(A)+1):
        if a > 9:
            a = int(str(a)[0]) + int(B[-k])*int(A[-j])
        else:
            a = int(B[-k])*int(A[-j])
        #print(a)
 
        p[k-1].append(int(str(a)[-1]))
        if j == len(A) and a >9:
            p[k-1].append(int(str(a)[0]))
 
for k in range(len(B)):
    for j in range(len(p[-1]) - len(p[k])):
        p[k].append(0)
 
#print(p)
a = 0
for k in range(len(p[0])): 
    if int(a) > 9: 
        a = int(str(a)[0])
    else:
        a =0
    for j in range(len(p)):
        a += p[j][k]
    ans.append(str(a)[-1])
    if k ==  len(p[0]-1) and a >9:
        ans.append(str(a)[0])

 
#print(ans)
op = ""
for k in range(1, len(ans)-1):
    op += ans[-k]
if len(ans)<3:
    print("0")
else:
    print(op)

Buggy submission (verdict: Runtime Error):
A, B = map(str, input().split())
 
B = str(int(float(B)*100+0.00001))
 
#print(B)
ans = []
p = [[]for k in range(len(B))]
for k in range(len(B)):
    for j in range(k):
        p[k].append(0)
for k in range(1, len(B)+1):
    a = 0
    for j in range(1, len(A)+1):
        if a > 9:
            a = int(str(a)[0]) + int(B[-k])*int(A[-j])
        else:
            a = int(B[-k])*int(A[-j])
        #print(a)
 
        p[k-1].append(int(str(a)[-1]))
        if j == len(A) and a >9:
            p[k-1].append(int(str(a)[0]))
 
for k in range(len(B)):
    for j in range(len(p[-1]) - len(p[k])):
        p[k].append(0)
 
#print(p)
a = 0
for k in range(len(p[0])): 
    if int(a) > 9: 
        a = int(str(a)[0])
    else:
        a =0
    for j in range(len(p)):
        a += p[j][k]
    ans.append(str(a)[-1])
    if k ==  len(p[0]-1) and a >9:
        ans.append(str(a)[0])
 
p
 
#print(ans)
op = ""
for k in range(1, len(ans)-1):
    op += ans[-k]
if len(ans)<3:
    print("0")
else:
    print(op)

Buggy submission (verdict: Runtime Error):
A, B = map(str, input().split())
 
B = str(int(float(B)*100) + 0.0001)
 
#print(B)
ans = []
p = [[]for k in range(len(B))]
for k in range(len(B)):
    for j in range(k):
        p[k].append(0)
for k in range(1, len(B)+1):
    a = 0
    for j in range(1, len(A)+1):
        if a > 9:
            a = int(str(a)[0]) + int(B[-k])*int(A[-j])
        else:
            a = int(B[-k])*int(A[-j])
        #print(a)
 
        p[k-1].append(int(str(a)[-1]))
        if j == len(A) and a >9:
            p[k-1].append(int(str(a)[0]))
 
for k in range(len(B)):
    for j in range(len(p[-1]) - len(p[k])):
        p[k].append(0)
 
#print(p)
a = 0
for k in range(len(p[0])): 
    if int(a) > 9: 
        a = int(str(a)[0])
    else:
        a =0
    for j in range(len(p)):
        a += p[j][k]
    ans.append(str(a)[-1])
 
#print(ans)
op = ""
for k in range(1, len(ans)-1):
    op += ans[-k]
if len(ans)<3:
    print("0")
else:
    print(op)