Buggy python submission (verdict: Time Limit Exceeded):
s = input()
from collections import deque
z = deque([0])
for i in range(len(s)):
    z.append(int(s[i:])%2019)

from collections import Counter
q = Counter(z)

ans=0
for i in q.values():
    ans+=i*(i-1)//2
print(ans)

Fixed submission:
import collections
s = input()
u = collections.deque([0])
for i in range(len(s)):
    u.append((u[i]+int(s[-i-1])*10**(i%224))%2019)
u2 = collections.Counter(u)
sum = 0
for i in u2.values():
    sum += i*(i-1)/2
print(int(sum))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
z = [0]
for i in range(len(s)):
    z.append(int(s[i:])%2019)

from collections import Counter
q = Counter(z)

ans=0
for i in q.values():
    ans+=i*(i-1)//2
print(ans)

Fixed submission:
import collections
s = input()
u = collections.deque([0])
for i in range(len(s)):
    u.append((u[i]+int(s[-i-1])*10**(i%224))%2019)
u2 = collections.Counter(u)
sum = 0
for i in u2.values():
    sum += i*(i-1)/2
print(int(sum))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
z = [0]
for i in range(len(s)):
    z.append(int(s[i:])%2019)

from collections import Counter
q = Counter(z)

ans=0
for i in q.values():
    ans+=i*(i-1)//2
print(ans)

Fixed submission:
import collections
s = input()
u = collections.deque([0])
for i in range(len(s)):
    u.append((u[i]+int(s[-i-1])*10**(i%224))%2019)
u2 = collections.Counter(u)
sum = 0
for i in u2.values():
    sum += i*(i-1)/2
print(int(sum))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
s = input()
u = collections.deque([0])
for i in range(len(s)):
    u.append((u[i]+int(s[::-1][i])*10**(i%224))%2019)
u2 = collections.Counter(u)
sum = 0
for i in u2.values():
    sum += i*(i-1)/2
print(int(sum))

Fixed submission:
import collections
s = input()
u = collections.deque([0])
for i in range(len(s)):
    u.append((u[i]+int(s[-i-1])*10**(i%224))%2019)
u2 = collections.Counter(u)
sum = 0
for i in u2.values():
    sum += i*(i-1)/2
print(int(sum))

Buggy python submission (verdict: Time Limit Exceeded):
import collections
s = input()
u = collections.deque([0])
for i in range(len(s)):
    u.append((u[i]+int(s[::-1][i])*10**i)%2019)
u2 = collections.Counter(u)
print(sum([int(i*(i-1)/2) for i in u2.values()]))

Fixed submission:
import collections
s = input()
u = collections.deque([0])
for i in range(len(s)):
    u.append((u[i]+int(s[-i-1])*10**(i%224))%2019)
u2 = collections.Counter(u)
sum = 0
for i in u2.values():
    sum += i*(i-1)/2
print(int(sum))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()
u = [0]
for i in range(len(s)):
    u.append((u[i]+int(s[::-1][i])*10**i)%2019)
import collections
u2 = collections.Counter(u)
print(sum([int(i*(i-1)/2) for i in u2.values()]))

Fixed submission:
import collections
s = input()
u = collections.deque([0])
for i in range(len(s)):
    u.append((u[i]+int(s[-i-1])*10**(i%224))%2019)
u2 = collections.Counter(u)
sum = 0
for i in u2.values():
    sum += i*(i-1)/2
print(int(sum))

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

count=0

for i in range(n):
    for j in range(i+1,n+1):
        if int(s[i:j])%2019==0:
            count+=1

print(count)

Fixed submission:
import collections
s = input()
u = collections.deque([0])
for i in range(len(s)):
    u.append((u[i]+int(s[-i-1])*10**(i%224))%2019)
u2 = collections.Counter(u)
sum = 0
for i in u2.values():
    sum += i*(i-1)/2
print(int(sum))