Buggy python submission (verdict: Time Limit Exceeded):
s=list(map(int,list(input())))[::-1]

n=len(s)
D=[0]*(n+1)
c=[0]*(n+1)
ans = 0
f = 0
dp = [0]*(2020)
dp[0]+=1

for e,i in enumerate(s):
    D[e]= i*pow(10,e)%2019
    if e!=0:
        c[e] = (c[e-1] + D[e])%2019
    else:
        c[e] = D[e]
    ans += dp[c[e]]
    dp[c[e]]+=1
# print(c)

# for e, i in enumerate(dp):
#     if i!=0:
#         print(e,i)
print(ans)

Fixed submission:
s=list(map(int,list(input())))[::-1]

n=len(s)
D=[0]*(n+1)
c=[0]*(n+1)
ans = 0
f = 0
dp = [0]*(2020)
dp[0]+=1
tmp =0
x = 1
for e,i in enumerate(s):
    tmp = (tmp+x*i)%2019
    ans += dp[tmp]
    dp[tmp]+=1
    x = x*10 %2019
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=list(map(int,list(input())))[::-1]

n=len(s)
D=[0]*(n+1)
c=[0]*(n+1)

# print(s)
for e,i in enumerate(s):
    D[e]= i*pow(10,e)%2019
# print(D)
c[0] = D[0]
for e,i in enumerate(s):
    if e==0:continue
    c[e] = (c[e-1] + D[e])%2019
# print(c)
ans = 0
f = 0
dp = [0]*(2020)
for e,i in enumerate(c):
    ans +=dp[i]
    dp[i]+=1
print(ans)

Fixed submission:
s=list(map(int,list(input())))[::-1]

n=len(s)
D=[0]*(n+1)
c=[0]*(n+1)
ans = 0
f = 0
dp = [0]*(2020)
dp[0]+=1
tmp =0
x = 1
for e,i in enumerate(s):
    tmp = (tmp+x*i)%2019
    ans += dp[tmp]
    dp[tmp]+=1
    x = x*10 %2019
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=list(map(int,list(input())))[::-1]

n=len(s)
D=[0]*(n+1)
c=[0]*(n+1)

# print(s)
for e,i in enumerate(s):
    D[e]= i*pow(10,e)%2019
# print(D)
c[0] = D[0]
for e,i in enumerate(s):
    if e==0:continue
    c[e] = (c[e-1] + D[e])%2019
# print(c)
ans = 0
f = 0
dp = [0]*(2020)
for e,i in enumerate(c):
    ans +=dp[i]
    dp[i]+=1
print(ans)

Fixed submission:
s=list(map(int,list(input())))[::-1]

n=len(s)
D=[0]*(n+1)
c=[0]*(n+1)
ans = 0
f = 0
dp = [0]*(2020)
dp[0]+=1
tmp =0
x = 1
for e,i in enumerate(s):
    tmp = (tmp+x*i)%2019
    ans += dp[tmp]
    dp[tmp]+=1
    x = x*10 %2019
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
A = input()
a = int(A)
ans  = 0 

for i in range(len(A)):
    for j in range(i+5,len(A)+1):
        t = A[i:j]
        ans += (int(t)%2019==0)
            # print(t)
# print(ans)

L =[]
for i in range(len(A)):
    t = A[i:i+4]
    L.append(int(t)%2019)
B = 0
for i in range(len(L)):
    T = L[i]
    for j in range(i+1,len(L)-3):
        T = 10*T+int(A[3+j])
        if T%2019==0:
            B+=1
            # print('w',T)
print(B)

Fixed submission:
s=list(map(int,list(input())))[::-1]

n=len(s)
D=[0]*(n+1)
c=[0]*(n+1)
ans = 0
f = 0
dp = [0]*(2020)
dp[0]+=1
tmp =0
x = 1
for e,i in enumerate(s):
    tmp = (tmp+x*i)%2019
    ans += dp[tmp]
    dp[tmp]+=1
    x = x*10 %2019
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

A = input()
a = int(A)
ans  = 0 
for i in range(len(A)):
    for j in range(i+4,len(A)+1):
        t = A[i:j]
        ans += (int(t)%2019==0)
print(ans)

Fixed submission:
s=list(map(int,list(input())))[::-1]

n=len(s)
D=[0]*(n+1)
c=[0]*(n+1)
ans = 0
f = 0
dp = [0]*(2020)
dp[0]+=1
tmp =0
x = 1
for e,i in enumerate(s):
    tmp = (tmp+x*i)%2019
    ans += dp[tmp]
    dp[tmp]+=1
    x = x*10 %2019
print(ans)