Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
d = 1
for char in s:
    temp += int(char)*d
    temp %= 2019
    amari[temp] += 1
    d *= 10

ans = 0
for i in amari:
    ans += i*(i-1)/2

print(int(ans))



Fixed submission:
s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
d = 1
for char in s:
    temp += int(char)*d
    temp %= 2019
    d *= 10
    d %= 2019  
    amari[temp] += 1

ans = 0
for i in amari:
    ans += i*(i-1)/2

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
d = 1
for char in s:
    temp += int(char)*d
    index = temp%2019
    amari[index] += 1
    d *= 10

ans = 0
for i in amari:
    ans += i*(i-1)/2

print(int(ans))



Fixed submission:
s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
d = 1
for char in s:
    temp += int(char)*d
    temp %= 2019
    d *= 10
    d %= 2019  
    amari[temp] += 1

ans = 0
for i in amari:
    ans += i*(i-1)/2

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
d = 1
for char in s:
    temp += int(char)*d
    amari[temp%2019] += 1
    d *= 10

ans = 0
for i in amari:
    ans += i*(i-1)/2

print(int(ans))



Fixed submission:
s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
d = 1
for char in s:
    temp += int(char)*d
    temp %= 2019
    d *= 10
    d %= 2019  
    amari[temp] += 1

ans = 0
for i in amari:
    ans += i*(i-1)/2

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
d = 1
for char in s:
    temp += int(char)*10*d
    amari[temp%2019] += 1
    d *= 10

ans = 0
for i in amari:
    ans += i*(i-1)/2

print(int(ans))













Fixed submission:
s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
d = 1
for char in s:
    temp += int(char)*d
    temp %= 2019
    d *= 10
    d %= 2019  
    amari[temp] += 1

ans = 0
for i in amari:
    ans += i*(i-1)/2

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
d = 1
for char in s:
    temp += int(char)*10*d
    amari[temp%2019] += 1
    d *= 10

ans = 0
for i in amari:
    ans += i*(i-1)/2

print(int(ans))

Fixed submission:
s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
d = 1
for char in s:
    temp += int(char)*d
    temp %= 2019
    d *= 10
    d %= 2019  
    amari[temp] += 1

ans = 0
for i in amari:
    ans += i*(i-1)/2

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
for i in range(n):
    temp += int(s[i])*10**i
    amari[temp%2019] += 1

ans = 0
frag = False
for i in amari:
    ans += i*(i-1)/2

print(int(ans))



Fixed submission:
s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
d = 1
for char in s:
    temp += int(char)*d
    temp %= 2019
    d *= 10
    d %= 2019  
    amari[temp] += 1

ans = 0
for i in amari:
    ans += i*(i-1)/2

print(int(ans))

Buggy python submission (verdict: Time Limit Exceeded):
s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
for i in range(n):
    temp += int(s[i])*10**i
    amari[temp%2019] += 1

ans = 0
frag = False
for i in amari:
    ans += i*(i-1)/2

print(int(ans))



Fixed submission:
s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
d = 1
for char in s:
    temp += int(char)*d
    temp %= 2019
    d *= 10
    d %= 2019  
    amari[temp] += 1

ans = 0
for i in amari:
    ans += i*(i-1)/2

print(int(ans))

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

if l < 4:
    print(0)
    exit()

ans = 0
for i in range(0,l-3):
    temp = int(s[i])
    for j in range(i+1,l):
        temp = temp*10 + int(s[j])
        num = int(temp)
        if num%2019 == 0:
            ans += 1

print(ans)

Fixed submission:
s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
d = 1
for char in s:
    temp += int(char)*d
    temp %= 2019
    d *= 10
    d %= 2019  
    amari[temp] += 1

ans = 0
for i in amari:
    ans += i*(i-1)/2

print(int(ans))

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

if l < 4:
    print(0)
    exit()

ans = 0
for i in range(0,l-3):
    temp = int(s[i])
    for j in range(i+1,l):
        temp = temp*10 + int(s[j])
        num = int(temp)
        if num%2019 == 0:
            ans += 1

print(ans)

Fixed submission:
s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
d = 1
for char in s:
    temp += int(char)*d
    temp %= 2019
    d *= 10
    d %= 2019  
    amari[temp] += 1

ans = 0
for i in amari:
    ans += i*(i-1)/2

print(int(ans))

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

if l < 4:
    print(0)
    exit()

ans = 0
for i in range(0,l-3):
    for j in range(i+1,l+1):
        temp = int(s[i:j])
        if temp%2019 == 0:
            ans += 1

print(ans)

Fixed submission:
s = input()[::-1]
n = len(s)
amari = [0]*2019
amari[0] = 1

temp = 0
d = 1
for char in s:
    temp += int(char)*d
    temp %= 2019
    d *= 10
    d %= 2019  
    amari[temp] += 1

ans = 0
for i in amari:
    ans += i*(i-1)/2

print(int(ans))