Buggy python submission (verdict: Runtime Error):
input()
s=s[::-1]
n=len(s)
 
count=[0]*2019
count[0]=1
num,d=0,1
 
for i in s:
  num+=int(i)*d
  num%=2019
  d*=10
  d%=2019
  count[num]+=1
 
ans=0
for i in count:
  ans+=i*(i-1)//2
  
print(ans)

Fixed submission:
s=input()
s=s[::-1]
n=len(s)
 
count=[0]*2019
count[0]=1
num,d=0,1
 
for i in s:
  num+=int(i)*d
  num%=2019
  d*=10
  d%=2019
  count[num]+=1
 
ans=0
for i in count:
  ans+=i*(i-1)//2
  
print(ans)

Buggy python submission (verdict: Runtime Error):
nput()
s=s[::-1]
n=len(s)
 
count=[0]*2019
count[0]=1
num,d=0,1
 
for i in s:
  num+=int(i)*d
  num%=2019
  d*=10
  d%=2019
  count[num]+=1
 
ans=0
for i in count:
  ans+=i*(i-1)//2
  
print(ans)

Fixed submission:
s=input()
s=s[::-1]
n=len(s)
 
count=[0]*2019
count[0]=1
num,d=0,1
 
for i in s:
  num+=int(i)*d
  num%=2019
  d*=10
  d%=2019
  count[num]+=1
 
ans=0
for i in count:
  ans+=i*(i-1)//2
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
s=s[::-1]
#print(s) #並び替え
n=len(s)
 
count=[0]*2019
count[0]=1
num,d=0,1
 
for i in s:
  num+=int(i)*d
  #print(d)
  #print(i,num)
  num%=2019
  d*=10
  #print(num)
  #d%=2019
  count[num]+=1
  
ans=0
for i in count:
  ans+=i*(i-1)//2
  
print(ans)

Fixed submission:
s=input()
s=s[::-1]
n=len(s)
 
count=[0]*2019
count[0]=1
num,d=0,1
 
for i in s:
  num+=int(i)*d
  num%=2019
  d*=10
  d%=2019
  count[num]+=1
 
ans=0
for i in count:
  ans+=i*(i-1)//2
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
s=input()
s=s[::-1] #並び替え
#print(s) 
n=len(s)
 
count=[0]*2019 
count[0]=1
num,d=0,1
 
for i in s:
  num+=int(i)*d #累積を求める
  a=num
  a=num%2019 #余りを求める
  d*=10
  count[a]+=1 #indexがmodの値
  
ans=0
for i in count: #何通りか
  ans+=i*(i-1)//2 # ex)3つあったら3通り、4つあったら6通り
  
print(ans)

Fixed submission:
s=input()
s=s[::-1]
n=len(s)
 
count=[0]*2019
count[0]=1
num,d=0,1
 
for i in s:
  num+=int(i)*d
  num%=2019
  d*=10
  d%=2019
  count[num]+=1
 
ans=0
for i in count:
  ans+=i*(i-1)//2
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

n = int(input())  # nは入力回数
l = [int(x) for x in list(str(n))]

num=len(l)
count=0

for i in range(num-3): 
    for j in range(3,num):
        if i>=j or j-i<3:
            pass
        else:
            new_n = int(reduce(lambda x, y: x + y, [str(x) for x in l[i:j+1]]))
            if new_n%2019==0:
              count=count+1  
print(count)
    

Fixed submission:
s=input()
s=s[::-1]
n=len(s)
 
count=[0]*2019
count[0]=1
num,d=0,1
 
for i in s:
  num+=int(i)*d
  num%=2019
  d*=10
  d%=2019
  count[num]+=1
 
ans=0
for i in count:
  ans+=i*(i-1)//2
  
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce

n = int(input())  # nは入力回数
l = [int(x) for x in list(str(n))]

num=len(l)
count=0

for i in range(num): 
    for j in range(num):
        if i>=j or j-i<3:
            pass
        else:
            new_n = int(reduce(lambda x, y: x + y, [str(x) for x in l[i:j+1]]))
            if new_n%2019==0:
              count=count+1  
print(count)
    

Fixed submission:
s=input()
s=s[::-1]
n=len(s)
 
count=[0]*2019
count[0]=1
num,d=0,1
 
for i in s:
  num+=int(i)*d
  num%=2019
  d*=10
  d%=2019
  count[num]+=1
 
ans=0
for i in count:
  ans+=i*(i-1)//2
  
print(ans)