Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter,deque
from scipy import special
S = input()
l = [int(n) for n in S]
a = [0]
t = 0
m = 1
d = deque(l)
while d:
    temp = d.pop()
    t += temp*m
    m *= 10
    a.append(t%2019)
b = [special.comb(kv,2,exact=True) for kv in Counter(a).values() if kv > 1]
print(sum(b))

Fixed submission:
from collections import Counter,deque
from scipy import special
S = input()
l = [int(n) for n in S]
a = [0]
t = 0
m = 1
d = deque(l)
mod = 2019
while d:
    temp = d.pop()
    t = (t + (temp * m)) % mod
    m = (m * 10) % mod
    a.append(t%mod)
b = [special.comb(kv,2,exact=True) for kv in Counter(a).values() if kv > 1]
print(sum(b))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
S = input()
a = [0,int(S)%2019]
init = 0
for i in range(len(S)-1):
    S = S[1:]
    a.append(int(S)%2019)
b = [kv*(kv-1)//2 for kv in Counter(a).values() if kv > 1]
print(sum(b))

Fixed submission:
from collections import Counter,deque
from scipy import special
S = input()
l = [int(n) for n in S]
a = [0]
t = 0
m = 1
d = deque(l)
mod = 2019
while d:
    temp = d.pop()
    t = (t + (temp * m)) % mod
    m = (m * 10) % mod
    a.append(t%mod)
b = [special.comb(kv,2,exact=True) for kv in Counter(a).values() if kv > 1]
print(sum(b))

Buggy python submission (verdict: Runtime Error):
S = input()
a = [0,int(S)%2019]
init = 0
for i in range(len(S)-1):
    S = S[1:]
    a.append(int(S)%2019)
b = [kv*(kv-1)//2 for kv in Counter(a).values() if kv > 1]
print(sum(b))

Fixed submission:
from collections import Counter,deque
from scipy import special
S = input()
l = [int(n) for n in S]
a = [0]
t = 0
m = 1
d = deque(l)
mod = 2019
while d:
    temp = d.pop()
    t = (t + (temp * m)) % mod
    m = (m * 10) % mod
    a.append(t%mod)
b = [special.comb(kv,2,exact=True) for kv in Counter(a).values() if kv > 1]
print(sum(b))

Buggy python submission (verdict: Runtime Error):
S = input()
l = [int(n) for n in list(S)]
a = [0,int(S)%2019]
init = 0
for i in range(len(S)-1):
    S = S[1:]
    a.append(int(S)%2019)
b = [kv*(kv-1)//2 for kv in Counter(a).values() if kv > 1]
print(sum(b))

Fixed submission:
from collections import Counter,deque
from scipy import special
S = input()
l = [int(n) for n in S]
a = [0]
t = 0
m = 1
d = deque(l)
mod = 2019
while d:
    temp = d.pop()
    t = (t + (temp * m)) % mod
    m = (m * 10) % mod
    a.append(t%mod)
b = [special.comb(kv,2,exact=True) for kv in Counter(a).values() if kv > 1]
print(sum(b))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter,deque
from scipy import special
def pow_k(x, n):
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K = (K * x)
        x = (x * x)
        n //= 2
    return (K * x)
S = input()
l = [int(n) for n in list(S)]
a = [0]
init = 0
i = 0
d = deque(l)
while d:
    temp = d.pop()
    init += temp*pow_k(10,i)
    a.append(init%2019)
    i += 1
b = [special.comb(kv,2,exact=True) for kv in Counter(a).values() if kv > 1]
print(sum(b))

Fixed submission:
from collections import Counter,deque
from scipy import special
S = input()
l = [int(n) for n in S]
a = [0]
t = 0
m = 1
d = deque(l)
mod = 2019
while d:
    temp = d.pop()
    t = (t + (temp * m)) % mod
    m = (m * 10) % mod
    a.append(t%mod)
b = [special.comb(kv,2,exact=True) for kv in Counter(a).values() if kv > 1]
print(sum(b))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from scipy import special
S = input()
a = [int(S[i:]) % 2019 for i in range(len(S))]
a.append(0)
b = [kv[1]*(kv[1]-1)//2 for kv in Counter(a).items() if kv[1] > 1]
print(sum(b))

Fixed submission:
from collections import Counter,deque
from scipy import special
S = input()
l = [int(n) for n in S]
a = [0]
t = 0
m = 1
d = deque(l)
mod = 2019
while d:
    temp = d.pop()
    t = (t + (temp * m)) % mod
    m = (m * 10) % mod
    a.append(t%mod)
b = [special.comb(kv,2,exact=True) for kv in Counter(a).values() if kv > 1]
print(sum(b))