Buggy python submission (verdict: Time Limit Exceeded):
s = input()
len_s = len(s)
pre = 0
mod = [0]*2019
mod[0]=1
x = 1
for i in range(len_s):
    pre = (x*int(s[len_s-i-1])+pre)%2019
    mod[pre] += 1
    x *= 10
sum_mod = 0
for m in mod:
    sum_mod += m*(m-1)//2
print(sum_mod)

Fixed submission:
s = input()
len_s = len(s)
pre = 0
mod = [0]*2019
mod[0]=1
x = 1
for i in range(len_s):
    pre = (x*int(s[len_s-i-1])+pre)%2019
    mod[pre] += 1
    x *= 10
    x %= 2019
print(sum([m*(m-1)//2 for m in mod]))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
len_s = len(s)
pre,now = 0,0
mod = [0]*2019
mod[0]=1
for i in range(len_s):
    now = (10**i*int(s[len_s-i-1])+pre)%2019
    mod[now] += 1
    pre = now
sum_mod = 0
for m in mod:
    sum_mod += m*(m-1)//2
print(sum_mod)

Fixed submission:
s = input()
len_s = len(s)
pre = 0
mod = [0]*2019
mod[0]=1
x = 1
for i in range(len_s):
    pre = (x*int(s[len_s-i-1])+pre)%2019
    mod[pre] += 1
    x *= 10
    x %= 2019
print(sum([m*(m-1)//2 for m in mod]))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
len_s = len(s)
pre,now = 0,0
mod = [0]*2019
mod[0]=1
for i in range(len_s):
    now = (10**i*int(s[len_s-i-1])+pre)%2019
    mod[now] += 1
    pre = now
sum_mod = 0
for m in mod:
    sum_mod += m*(m-1)//2
print(sum_mod)

Fixed submission:
s = input()
len_s = len(s)
pre = 0
mod = [0]*2019
mod[0]=1
x = 1
for i in range(len_s):
    pre = (x*int(s[len_s-i-1])+pre)%2019
    mod[pre] += 1
    x *= 10
    x %= 2019
print(sum([m*(m-1)//2 for m in mod]))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
c = 0
for i in range(len(s)):
    for j in range(i+4,len(s)+1):
        a = int(s[i:j])
        if a>=2019:
            if a%3==0:
                if a%673==0:
                    c += 1
print(c)

Fixed submission:
s = input()
len_s = len(s)
pre = 0
mod = [0]*2019
mod[0]=1
x = 1
for i in range(len_s):
    pre = (x*int(s[len_s-i-1])+pre)%2019
    mod[pre] += 1
    x *= 10
    x %= 2019
print(sum([m*(m-1)//2 for m in mod]))

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

Fixed submission:
s = input()
len_s = len(s)
pre = 0
mod = [0]*2019
mod[0]=1
x = 1
for i in range(len_s):
    pre = (x*int(s[len_s-i-1])+pre)%2019
    mod[pre] += 1
    x *= 10
    x %= 2019
print(sum([m*(m-1)//2 for m in mod]))

Buggy python submission (verdict: Runtime Error):
s = input()
c = 0
for i in range(len(s)):
    for j in range(i+4,len(s)+1):
        a = int(s[i:j])
        if a>=2019 and a%3==0 a%673==0:
            c += 1
print(c)

Fixed submission:
s = input()
len_s = len(s)
pre = 0
mod = [0]*2019
mod[0]=1
x = 1
for i in range(len_s):
    pre = (x*int(s[len_s-i-1])+pre)%2019
    mod[pre] += 1
    x *= 10
    x %= 2019
print(sum([m*(m-1)//2 for m in mod]))

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

Fixed submission:
s = input()
len_s = len(s)
pre = 0
mod = [0]*2019
mod[0]=1
x = 1
for i in range(len_s):
    pre = (x*int(s[len_s-i-1])+pre)%2019
    mod[pre] += 1
    x *= 10
    x %= 2019
print(sum([m*(m-1)//2 for m in mod]))

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

Fixed submission:
s = input()
len_s = len(s)
pre = 0
mod = [0]*2019
mod[0]=1
x = 1
for i in range(len_s):
    pre = (x*int(s[len_s-i-1])+pre)%2019
    mod[pre] += 1
    x *= 10
    x %= 2019
print(sum([m*(m-1)//2 for m in mod]))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
c = 0
for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        if int(s[i:j])%2019 == 0:
            c+=1
print(c)

Fixed submission:
s = input()
len_s = len(s)
pre = 0
mod = [0]*2019
mod[0]=1
x = 1
for i in range(len_s):
    pre = (x*int(s[len_s-i-1])+pre)%2019
    mod[pre] += 1
    x *= 10
    x %= 2019
print(sum([m*(m-1)//2 for m in mod]))