Buggy python submission (verdict: Time Limit Exceeded):
mods = [0]*2019
mods[0] = 1
s = input()
u = 1
t = 0
for i in range(1,len(s)+1):
    k = len(s) - i
    t = (t + int(s[k])*u)%2019
    u *= 10 % 2019
    mods[t] += 1


cnt = 0
for x in mods:
    if x >= 2:
        cnt += x*(x-1)/2
print(int(cnt))

Fixed submission:
mods = [0]*2019
mods[0] = 1
s = input()
t = 0
u = 1
for i in range(1,len(s)+1):
    t = (t + int(s[-i])*u)%2019
    u = u*10%2019
    mods[t] += 1


cnt = 0
for x in mods:
    if x >= 2:
        cnt += x*(x-1)/2
print(int(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
mods = [0]*2019
mods[0] = 1
s = input()
u = 1
t = 0
for i in range(1,len(s)+1):
    k = len(s) - i
    t = (t + int(s[k])*u)%2019
    u *= 10 % 2019
    mods[t] += 1


cnt = 0
for x in mods:
    if x >= 2:
        cnt += x*(x-1)//2
print(cnt)

Fixed submission:
mods = [0]*2019
mods[0] = 1
s = input()
t = 0
u = 1
for i in range(1,len(s)+1):
    t = (t + int(s[-i])*u)%2019
    u = u*10%2019
    mods[t] += 1


cnt = 0
for x in mods:
    if x >= 2:
        cnt += x*(x-1)/2
print(int(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
mods = [0]*2019
mods[0] = 1
s = input()
dp = [0]*(len(s)+1)
u = 1
for i in range(1,len(s)+1):
    k = len(s) - i
    dp[i] = (dp[i-1] + int(s[k])*u)%2019
    u *= 10
    mods[dp[i]] += 1


cnt = 0
for x in mods:
    if x >= 2:
        cnt += x*(x-1)//2
print(cnt)

Fixed submission:
mods = [0]*2019
mods[0] = 1
s = input()
t = 0
u = 1
for i in range(1,len(s)+1):
    t = (t + int(s[-i])*u)%2019
    u = u*10%2019
    mods[t] += 1


cnt = 0
for x in mods:
    if x >= 2:
        cnt += x*(x-1)/2
print(int(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
mods = [0]*2019
mods[0] = 1
s = input()
dp = [0 for i in range(len(s)+1)]
u = 1
for i in range(1,len(s)+1):
    k = len(s) - i
    dp[i] = (dp[i-1] + int(s[k])*u)%2019
    u *= 10%2019
    mods[dp[i]] += 1


cnt = 0
for x in mods:
    if x >= 2:
        cnt += x*(x-1)//2
print(cnt)

Fixed submission:
mods = [0]*2019
mods[0] = 1
s = input()
t = 0
u = 1
for i in range(1,len(s)+1):
    t = (t + int(s[-i])*u)%2019
    u = u*10%2019
    mods[t] += 1


cnt = 0
for x in mods:
    if x >= 2:
        cnt += x*(x-1)/2
print(int(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
mods = [0]*2019
mods[0] = 1
s = input()
dp = [0 for i in range(len(s)+1)]
u = 1
for i in range(1,len(s)+1):
    k = len(s) - i
    dp[i] = (dp[i-1] + int(s[k])*u)%2019
    u *= 10
    mods[dp[i]] += 1


cnt = 0
for x in mods:
    if x >= 2:
        cnt += x*(x-1)//2
print(cnt)

Fixed submission:
mods = [0]*2019
mods[0] = 1
s = input()
t = 0
u = 1
for i in range(1,len(s)+1):
    t = (t + int(s[-i])*u)%2019
    u = u*10%2019
    mods[t] += 1


cnt = 0
for x in mods:
    if x >= 2:
        cnt += x*(x-1)/2
print(int(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
mods = [0]*2019
mods[0] = 1
s = input()
dp = [0 for i in range(len(s)+1)]
for i in range(1,len(s)+1):
    k = len(s) - i
    dp[i] = (dp[i-1] + int(s[k])*(pow(10,i-1)))%2019
    mods[dp[i]] += 1


cnt = 0
for x in mods:
    if x >= 2:
        cnt += x*(x-1)//2
print(cnt)



Fixed submission:
mods = [0]*2019
mods[0] = 1
s = input()
t = 0
u = 1
for i in range(1,len(s)+1):
    t = (t + int(s[-i])*u)%2019
    u = u*10%2019
    mods[t] += 1


cnt = 0
for x in mods:
    if x >= 2:
        cnt += x*(x-1)/2
print(int(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
s = input()
dp = [0 for i in range(len(s)+1)]
for i in range(1,len(s)+1):
    k = len(s) - i
    dp[i] = (dp[i-1] + int(s[k])*(pow(10,i-1)))%2019

count_d = collections.defaultdict(int)
for mod in dp:
    count_d[mod] += 1

cnt = 0
for v in count_d.values():
    if v >= 2:
        cnt += v*(v-1)//2
print(cnt)

Fixed submission:
mods = [0]*2019
mods[0] = 1
s = input()
t = 0
u = 1
for i in range(1,len(s)+1):
    t = (t + int(s[-i])*u)%2019
    u = u*10%2019
    mods[t] += 1


cnt = 0
for x in mods:
    if x >= 2:
        cnt += x*(x-1)/2
print(int(cnt))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
s = input()
dp = [0 for i in range(len(s)+1)]
for i in range(1,len(s)+1):
    k = len(s) - i
    dp[i] = (dp[i-1] + int(s[k])*(10**(i-1)))%2019

count_d = collections.defaultdict(int)
for mod in dp:
    count_d[mod] += 1

cnt = 0
for v in count_d.values():
    if v >= 2:
        cnt += v*(v-1)//2
print(cnt)

Fixed submission:
mods = [0]*2019
mods[0] = 1
s = input()
t = 0
u = 1
for i in range(1,len(s)+1):
    t = (t + int(s[-i])*u)%2019
    u = u*10%2019
    mods[t] += 1


cnt = 0
for x in mods:
    if x >= 2:
        cnt += x*(x-1)/2
print(int(cnt))