Buggy python submission (verdict: Time Limit Exceeded):
n = input()
all_int = list()
ans = 0
for i in range(len(n)):
    for j in range(i+1,len(n)+1):
        s = n[i:j]
        if(int(s) > 0 and len(s)>=4 and int(s)%2019 == 0):
            ans += 1
print(ans)

Fixed submission:
s = list(input())
# s = list(str(10**200000))
n = len(s)
ans = 0
s.reverse()
# print(s)
x = 1
tot = 0
count = [0]*2019
for i in range(n):
    count[tot]+=1
    tot += int(s[i])*x
    # print(tot)
    tot %= 2019
    ans += count[tot]
    x = x*10%2019
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
count2019 = [0]*2019
count2019[0]=1
mod2019 = 0
d = 1
for i in S[::-1]:
    mod2019 =mod2019+int(i)*d
    mod2019%=2019
    count2019[mod2019] +=1
    d *= 10
    d%2019
ans =0
for i in count2019:
   ans+= i*(i-1)//2
print(ans)

Fixed submission:
s = list(input())
# s = list(str(10**200000))
n = len(s)
ans = 0
s.reverse()
# print(s)
x = 1
tot = 0
count = [0]*2019
for i in range(n):
    count[tot]+=1
    tot += int(s[i])*x
    # print(tot)
    tot %= 2019
    ans += count[tot]
    x = x*10%2019
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
count2019 = [0]*2019
count2019[0]=1
mod2019 = 0
d = 1
for i in S[::-1]:
    mod2019 =mod2019+int(i)*d
    mod2019%=2019
    count2019[mod2019] +=1
    d *= 10
    d%2019
ans =0
for i in count2019:
   ans+= i*(i-1)//2
print(ans)
# print(count2019)

Fixed submission:
s = list(input())
# s = list(str(10**200000))
n = len(s)
ans = 0
s.reverse()
# print(s)
x = 1
tot = 0
count = [0]*2019
for i in range(n):
    count[tot]+=1
    tot += int(s[i])*x
    # print(tot)
    tot %= 2019
    ans += count[tot]
    x = x*10%2019
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):


from math import factorial
S=list(map(int,input()))
S.reverse()
count2019 = [0]*2019
count2019[0]=1
mod2019 = 0
d = 1
for i in S:
    mod2019 =mod2019+int(i)*d
    mod2019%=2019
    count2019[mod2019] +=1
    d *= 10
    d%2019
ans =0
for i in count2019:
   ans+= i*(i-1)//2
print(ans)
# print(count2019)

Fixed submission:
s = list(input())
# s = list(str(10**200000))
n = len(s)
ans = 0
s.reverse()
# print(s)
x = 1
tot = 0
count = [0]*2019
for i in range(n):
    count[tot]+=1
    tot += int(s[i])*x
    # print(tot)
    tot %= 2019
    ans += count[tot]
    x = x*10%2019
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):


from math import factorial
S=list(map(int,input()))
S.reverse()
count2019 = [0]*2019
count2019[0]=1
mod2019 = 0
d = 1
for i in range(len(S)):
    mod2019 =mod2019+S[i]*d
    mod2019%=2019
    count2019[mod2019] +=1
    d *= 10
    d%2019
ans =0
for i in count2019:
   ans+= i*(i-1)//2
print(ans)
# print(count2019)

Fixed submission:
s = list(input())
# s = list(str(10**200000))
n = len(s)
ans = 0
s.reverse()
# print(s)
x = 1
tot = 0
count = [0]*2019
for i in range(n):
    count[tot]+=1
    tot += int(s[i])*x
    # print(tot)
    tot %= 2019
    ans += count[tot]
    x = x*10%2019
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):


from math import factorial
S=list(map(int,input()))
S.reverse()
count2019 = [0]*2019
count2019[0]=1
mod2019 = 0
for i in range(len(S)):
    mod2019 =(mod2019+S[i]*10**i)%2019
    count2019[mod2019] +=1

ans =0
for i in count2019:
   ans+= i*(i-1)//2
print(ans)
# print(count2019)

Fixed submission:
s = list(input())
# s = list(str(10**200000))
n = len(s)
ans = 0
s.reverse()
# print(s)
x = 1
tot = 0
count = [0]*2019
for i in range(n):
    count[tot]+=1
    tot += int(s[i])*x
    # print(tot)
    tot %= 2019
    ans += count[tot]
    x = x*10%2019
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
S=list(map(int,input()))
S.reverse()
# print(S)
count2019 = [0]*2019
count2019[0]=1
mod2019 = 0
for i in range(len(S)):
    mod2019 =(mod2019+S[i]*10**i)%2019
    count2019[mod2019] +=1

ans =0
for i in count2019:
    if(i>=2):
        ans += factorial(i) // factorial(i) // factorial(i - 2)
print(ans)
# print(count2019)

Fixed submission:
s = list(input())
# s = list(str(10**200000))
n = len(s)
ans = 0
s.reverse()
# print(s)
x = 1
tot = 0
count = [0]*2019
for i in range(n):
    count[tot]+=1
    tot += int(s[i])*x
    # print(tot)
    tot %= 2019
    ans += count[tot]
    x = x*10%2019
print(ans)

Buggy python submission (verdict: Runtime Error):
from math import factorial
S=list(map(int,input()))
S.reverse()
# print(S)
count2019 = [0]*2019
count2019[0]=1

for i in range(len(S)):
    mod2019 =(mod2019+S[i]*10**i)%2019
    count2019[mod2019] +=1

ans =0
for i in count2019:
    if(i>=2):
        ans += factorial(i) // factorial(i) // factorial(i - 2)
print(ans)
# print(count2019)

Fixed submission:
s = list(input())
# s = list(str(10**200000))
n = len(s)
ans = 0
s.reverse()
# print(s)
x = 1
tot = 0
count = [0]*2019
for i in range(n):
    count[tot]+=1
    tot += int(s[i])*x
    # print(tot)
    tot %= 2019
    ans += count[tot]
    x = x*10%2019
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
S=list(map(int,input()))
S.reverse()
# print(S)
count2019 = [0]*2019
count2019[0]=1
mod2019 = [0]*(len(S)+1)
for i in range(len(S)):
    mod2019[i+1] =mod2019[i]+S[i]*10**i 
    mod2019[i+1]%=2019
    count2019[mod2019[i+1]] +=1

ans =0
for i in count2019:
    if(i>=2):
        ans += factorial(i) // factorial(i) // factorial(i - 2)
print(ans)
# print(count2019)

Fixed submission:
s = list(input())
# s = list(str(10**200000))
n = len(s)
ans = 0
s.reverse()
# print(s)
x = 1
tot = 0
count = [0]*2019
for i in range(n):
    count[tot]+=1
    tot += int(s[i])*x
    # print(tot)
    tot %= 2019
    ans += count[tot]
    x = x*10%2019
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import factorial
S=list(map(int,input()))
S.reverse()
# print(S)
count2019 = [0]*2019
mod2019 = [0]*(len(S)+1)
for i in range(len(S)):
    mod2019[i+1] =mod2019[i]+S[i]*10**i 
    mod2019[i+1]%=2019
for i in mod2019:
    count2019[i] +=1
# print(mod2019)
ans =0
for i in count2019:
    if(i>=2):
        ans += factorial(i) // factorial(i) // factorial(i - 2)
print(ans)
# print(count2019)

Fixed submission:
s = list(input())
# s = list(str(10**200000))
n = len(s)
ans = 0
s.reverse()
# print(s)
x = 1
tot = 0
count = [0]*2019
for i in range(n):
    count[tot]+=1
    tot += int(s[i])*x
    # print(tot)
    tot %= 2019
    ans += count[tot]
    x = x*10%2019
print(ans)