Buggy python submission (verdict: Time Limit Exceeded):
a=input()
num=len(a)
mod_map={0:1}
moji_int=0
Sn=[0]*(num+1)
tens=[1]*(num+1)
for i in range(-1,-num-1,-1):
    tens[-i]=tens[-i-1]*10
    tmp=int(a[i])*(tens[-i-1]%2019)
    Sn[-i]=(Sn[-i-1]+tmp%2019)%2019
    mod=Sn[-i]
    if mod not in mod_map:
        mod_map[mod]=1
    else:
        mod_map[mod]+=1

res=0
for i in mod_map.values():
    res+=int(i*(i-1)/2)
print(res)


Fixed submission:
a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
a=input()
num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a[::-1]:
    tmp=int(i)*(tens%2019)
    Sn=(Sn+tmp%2019)%2019
    mod=Sn
    tens*=10
    mod_list[mod]+=1

res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)


Fixed submission:
a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
a=input()
num=len(a)
mod_map={0:1}
moji_int=0
Sn=0
tens=1
for i in a[::-1]:
    tmp=int(i)*(tens%2019)
    Sn=(Sn+tmp%2019)%2019
    mod=Sn
    tens*=10
    if mod not in mod_map:
        mod_map[mod]=1
    else:
        mod_map[mod]+=1


res=0
for i in mod_map.values():
    res+=int(i*(i-1)/2)
print(res)


Fixed submission:
a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
a=input()
num=len(a)
mod_map={0:1}
moji_int=0
Sn=0
tens=1
for i in range(-1,-num-1,-1):
    tmp=int(a[i])*(tens%2019)
    Sn=(Sn+tmp%2019)%2019
    mod=Sn
    tens*=10
    if mod not in mod_map:
        mod_map[mod]=1
    else:
        mod_map[mod]+=1

res=0
for i in mod_map.values():
    res+=int(i*(i-1)/2)
print(res)
    

Fixed submission:
a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
a=input()
num=len(a)
mod_map={0:1}
moji_int=0
Sn=0
tens=1
for i in range(-1,-num-1,-1):
    tmp=int(a[i])*(tens%2019)
    Sn=(Sn+tmp%2019)%2019
    mod=Sn
    tens*=10
    if mod not in mod_map:
        mod_map[mod]=1
    else:
        mod_map[mod]+=1

res=0
for i in mod_map.values():
    res+=int(i*(i-1)/2)
print(res)
    

Fixed submission:
a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
a=input()
num=len(a)
mod_map={0:1}
moji_int=0
Sn=0
tens=[1]*(num+1)
for i in range(-1,-num-1,-1):
    tens[-i]=tens[-i-1]*10
    tmp=int(a[i])*(tens[-i-1]%2019)
    Sn=(Sn+tmp%2019)%2019
    mod=Sn
    if mod not in mod_map:
        mod_map[mod]=1
    else:
        mod_map[mod]+=1

res=0
for i in mod_map.values():
    res+=int(i*(i-1)/2)
print(res)


Fixed submission:
a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
a=input()
num=len(a)
mod_map={0:1}
moji_int=0
Sn=0
tens=[1]*(num+1)
for i in range(-1,-num-1,-1):
    tens[-i]=tens[-i-1]*10
    tmp=int(a[i])*(tens[-i-1]%2019)
    Sn=(Sn+tmp%2019)%2019
    mod=Sn
    if mod not in mod_map:
        mod_map[mod]=1
    else:
        mod_map[mod]+=1

res=0
for i in mod_map.values():
    res+=int(i*(i-1)/2)
print(res)


Fixed submission:
a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
a=input()
num=len(a)
mod_map={0:1}
mod_list=[1]+[0]*2019
moji_int=0
Sn=[0]*(num+1)
tens=[1]*(num+1)
for i in range(-1,-num-1,-1):
    tens[-i]=tens[-i-1]*10
    tmp=int(a[i])*(tens[-i-1]%2019)
    Sn[-i]=(Sn[-i-1]+tmp%2019)%2019
    mod=Sn[-i]
    mod_list[mod]+=1

res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)


Fixed submission:
a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
a=input()
num=len(a)
mod_map={0:1}
mod_list=[1]+[0]*2019
moji_int=0
Sn=[0]*(num+1)
tens=[1]*(num+1)
for i in range(-1,-num-1,-1):
    tens[-i]=tens[-i-1]*10
    tmp=int(a[i])*(tens[-i-1]%2019)
    Sn[-i]=(Sn[-i-1]+tmp%2019)%2019
    mod=Sn[-i]
    mod_list[mod]+=1

res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)

Fixed submission:
a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
a=input()
num=len(a)
mod_map={0:1}
moji_int=0
Sn=[0]*(num+1)
tens=[1]*(num+1)
for i in range(-1,-num-1,-1):
    tens[-i]=tens[-i-1]*10
    tmp=int(a[i])*(tens[-i-1]%2019)
    Sn[-i]=(Sn[-i-1]+tmp%2019)%2019
    mod=Sn[-i]
    if mod not in mod_map:
        mod_map[mod]=1
    else:
        mod_map[mod]+=1

res=0
for i in mod_map.values():
    res+=int(i*(i-1)/2)
print(res)

Fixed submission:
a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
a=input()
num=len(a)
mod_map={0:1}
moji_int=0
Sn=[0]*(num+1)
tens=[1]*(num+1)
for i in range(-1,-num-1,-1):
    tens[-i]=tens[-i-1]*10
    tmp=int(a[i])*(tens[-i-1]%2019)
    Sn[-i]=(Sn[-i-1]+tmp%2019)%2019
    mod=Sn[-i]
    if mod not in mod_map:
        mod_map[mod]=1
    else:
        mod_map[mod]+=1

res=0
for i in mod_map.values():
    res+=int(i*(i-1)/2)
print(res)

Fixed submission:
a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
a=input()
num=len(a)
mod_map={0:1}
moji_int=0
for i in range(-1,-num-1,-1):
    moji_int+=int(a[i])*(10**(-i-1)%2019)
    mod=moji_int%2019
    if mod not in mod_map:
        mod_map[mod]=1
    else:
        mod_map[mod]+=1

res=0
for i in mod_map.values():
    res+=int(i*(i-1)/2)
print(res)

Fixed submission:
a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
a=input()
num=len(a)
mod_map={0:1}
moji_int=0
for i in range(-1,-num-1,-1):
    moji_int+=int(a[i])*10**(-i-1)
    mod=moji_int%2019
    if mod not in mod_map:
        mod_map[mod]=1
    else:
        mod_map[mod]+=1

res=0
for i in mod_map.values():
    res+=int(i*(i-1)/2)
print(res)

Fixed submission:
a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
a=input()
num=len(a)
mod_map={0:1}
moji_int=0
for i in range(-1,-num-1,-1):
    moji_int+=int(a[i])*10**(-i-1)
    mod=moji_int%2019
    if mod not in mod_map:
        mod_map[mod]=1
    else:
        mod_map[mod]+=1

res=0
for i in mod_map.values():
    res+=int(i*(i-1)/2)
print(res)

Fixed submission:
a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
a=input()
num=len(a)
mod_map={0:1}

for i in range(-1,-num-1,-1):
    mod=int(a[i:])%2019
    if mod not in mod_map:
        mod_map[mod]=1
    else:
        mod_map[mod]+=1
res=0
for i in mod_map.values():
    res+=int(i*(i-1)/2)
print(res)

Fixed submission:
a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
a=input()
counter=0
i=0
while i <len(a)-3:
    moji=a[i:i+3]
    for j in range(i+3,len(a)):
        moji+=a[j]
        if int(moji)%2019==0:
            counter+=1
            i=j-1
    i+=1
print(counter)

Fixed submission:
a=reversed(input())
#num=len(a)
mod_list=[1]+[0]*2019
moji_int=0
Sn=0
tens=1
for i in a:
    tmp=int(i)*(tens)
    Sn=(Sn+tmp)%2019
    mod=Sn
    tens=tens*10%2019
    mod_list[mod]+=1
res=0
for i in mod_list:
    res+=int(i*(i-1)/2)
print(res)