Buggy python submission (verdict: Time Limit Exceeded):
import collections as col
cnt = col.Counter()

s = input()
n = len(s)

for i in range(n+1):
    num = 0 if i==0 else int(s[-i:])
    cnt[num%2019] += 1

ans = 0
for key,val in cnt.items():
    ans += val*(val-1)//2

print(ans)


Fixed submission:
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * pow(10, i, 2019)
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * pow(10,i)
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)



Fixed submission:
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * pow(10, i, 2019)
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * (10**i % 2019)
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)



Fixed submission:
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * pow(10, i, 2019)
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * (10**i % 2019)
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)



Fixed submission:
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * pow(10, i, 2019)
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * 10**i
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)



Fixed submission:
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * pow(10, i, 2019)
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = ""
for i in range(1,n+1):
    num = s[-i] + num
    arr[int(num)%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)



Fixed submission:
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * pow(10, i, 2019)
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

for i in range(1,n+1):
    num = int(s[-i:])
    arr[num%2019] += 1

ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)



Fixed submission:
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * pow(10, i, 2019)
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

for i in range(1,n+1):
    num = int(s[-i:])
    arr[num%2019] += 1

ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)



Fixed submission:
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * pow(10, i, 2019)
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

for i in range(1,n+1):
    num = int(s[-i:])
    arr[num%2019] += 1

ans = 0
for i,m in enumerate(arr):
    if m==0: continue
    ans += m*(m-1)//2

print(ans)



Fixed submission:
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * pow(10, i, 2019)
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)

if n<5: ans = 0
else:
    ans = 0
    for i in range(n):
        for j in range(i+5, n+1):
            num = int(s[i:j])
            if int(num)%2019==0: ans += 1 ; continue

print(ans)


Fixed submission:
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * pow(10, i, 2019)
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)

if n<5: ans = 0
else:
    ans = 0
    for i in range(n):
        for j in range(i+5, n+1):
            num = int(s[i:j])
            if int(num)%2019==0: ans += 1

print(ans)


Fixed submission:
arr = [0 for i in range(2019)]
arr[0] = 1

s = input()
n = len(s)

num = 0
for i,ele in enumerate(s[::-1]):
    num += int(ele) * pow(10, i, 2019)
    arr[num%2019] += 1


ans = 0
for m in arr:
    if m==0: continue
    ans += m*(m-1)//2

print(ans)