Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = list(input())
n.reverse()
x = [0]*(len(n))
a=0
for i in range(len(n)):
    a+=int(n[i])*10**i
    x[i]=a%2019
c=Counter(x)
ans = c[0]
for i in c.keys():
    b=c[i]
    ans += b*(b-1)//2

print(ans)


Fixed submission:
from collections import Counter

n = list(input())
n.reverse()
x = [0]*(len(n))
a=0
ex=1
for i in range(len(n)):
    a+=int(n[i])*ex
    x[i]=a%2019
    ex=ex*10%2019
c=Counter(x)
ans = c[0]
for i in c.keys():
    b=c[i]
    ans += b*(b-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

n = list(input())
n.reverse()
x = [0]*(len(n))
a=0
for i in range(len(n)):
    a+=int(n[i])*10**i
    x[i]=a%2019
c=Counter(x)
cc=c.most_common()
ans = c[0]
for i in range(len(cc)):
    b=cc[i][1]
    ans += b*(b-1)//2

print(ans)


Fixed submission:
from collections import Counter

n = list(input())
n.reverse()
x = [0]*(len(n))
a=0
ex=1
for i in range(len(n)):
    a+=int(n[i])*ex
    x[i]=a%2019
    ex=ex*10%2019
c=Counter(x)
ans = c[0]
for i in c.keys():
    b=c[i]
    ans += b*(b-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

def combi(n,r):
    if n==0 or n==1:
        return 0
    ans=1
    for i in range(r):
        ans*=(n-i)
    for i in range(1,r+1):
        ans//=i
    return ans

n = list(input())
n.reverse()
x = [0]*(len(n))
a=0
for i in range(len(n)):
    a+=int(n[i])*10**i
    x[i]=a%2019
c=Counter(x)
cc=c.most_common()
ans = c[0]
for i in range(len(cc)):
    ans += combi(cc[i][1],2)

print(ans)


Fixed submission:
from collections import Counter

n = list(input())
n.reverse()
x = [0]*(len(n))
a=0
ex=1
for i in range(len(n)):
    a+=int(n[i])*ex
    x[i]=a%2019
    ex=ex*10%2019
c=Counter(x)
ans = c[0]
for i in c.keys():
    b=c[i]
    ans += b*(b-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

def combi(n,r):
    if n==0 or n==1:
        return 0
    ans=1
    for i in range(r):
        ans*=(n-i)
    for i in range(1,r+1):
        ans//=i
    return ans

n = list(input())
n.reverse()
x = []
a=0
for i in range(len(n)):
    a+=int(n[i])*10**i
    x.append(a%2019)
c=Counter(x)
cc=c.most_common()
ans = c[0]
for i in range(len(cc)):
    ans += combi(cc[i][1],2)

print(ans)


Fixed submission:
from collections import Counter

n = list(input())
n.reverse()
x = [0]*(len(n))
a=0
ex=1
for i in range(len(n)):
    a+=int(n[i])*ex
    x[i]=a%2019
    ex=ex*10%2019
c=Counter(x)
ans = c[0]
for i in c.keys():
    b=c[i]
    ans += b*(b-1)//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

def combi(n,r):
    if n==0 or n==1:
        return 0
    ans=1
    for i in range(1,n+1):
        ans*=i
    for i in range(1,r+1):
        ans//=i
    return ans

n = list(input())
n.reverse()
x = []
a=0
for i in range(len(n)):
    a+=int(n[i])*10**i
    x.append(a%2019)
c=Counter(x)
ans = c[0]
for i in range(1,2020):
    ans += combi(c[i],2)

print(ans)


Fixed submission:
from collections import Counter

n = list(input())
n.reverse()
x = [0]*(len(n))
a=0
ex=1
for i in range(len(n)):
    a+=int(n[i])*ex
    x[i]=a%2019
    ex=ex*10%2019
c=Counter(x)
ans = c[0]
for i in c.keys():
    b=c[i]
    ans += b*(b-1)//2

print(ans)

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

Fixed submission:
from collections import Counter

n = list(input())
n.reverse()
x = [0]*(len(n))
a=0
ex=1
for i in range(len(n)):
    a+=int(n[i])*ex
    x[i]=a%2019
    ex=ex*10%2019
c=Counter(x)
ans = c[0]
for i in c.keys():
    b=c[i]
    ans += b*(b-1)//2

print(ans)