Problem:


Score : 400 points

Problem Statement

Given is a string S consisting of digits from 1 through 9.

Find the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the following condition:

Condition: In base ten, the i-th through j-th characters of S form an integer that is a multiple of 2019.

Constraints

1 ≤ |S| ≤ 200000

S is a string consisting of digits from 1 through 9.

Input

Input is given from Standard Input in the following format:

S

Output

Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the condition.

Sample Input 1

1817181712114

Sample Output 1

3

Three pairs - (1,5), (5,9), and (9,13) - satisfy the condition.

Sample Input 2

14282668646

Sample Output 2

2

Sample Input 3

2119

Sample Output 3

0

No pairs satisfy the condition.



Sample input:
1817181712114


Sample output:
3

Submission status: Wrong Answer

Solution code:
S = input()
cnt = 0

length = len(S)
if length < 20000:
  for i in range(0,len(S)-4):
    for j in range(i+4,i+4+30):
      if int(S[i:j+1]) % 2019 == 0 and j<length:
        cnt += 1
  print(cnt)
else:
  print(0)

Submission status: Wrong Answer

Solution code:
y=input()
val=2019
m=len(y)
j=4
count=0
while j!=m-1:
    for i in range(m-j):
        for t in range(i+j,m):
            check=int(y[i:t])
            if check%val==0:
                count+=1
    j+=1
print(count)

Submission status: Wrong Answer

Solution code:
string=input()
count=0
times=1
length=4
while len(string) >= 4:
  target=int(string[:length])
  if len(string) <= length and target <= 200000 and target % 2019 == 0:
    count+=1
  length+=1
  if times % 3 == 0:
    length=4
    string=string[1:]
  times+=1
print(count)

Submission status: Wrong Answer

Solution code:
s = input()
c = 0

# for i in range(len(str(s))):
#     for j in range(i+1, len(str(s))+1):
#         tmp = s[i:j]
#         if int(tmp) % 2019 == 0:
#             c += 1

for i in range(1, 100):
    t = i * 2019
    if t > 200000:
        break
    # print(t)
    # print(len(str(t)))
    len_t = len(str(t))
    if str(s).count(str(t)) == 0:
        continue
    for i in range(len(str(s)) - (len_t - 1)):
        tmp = s[i:i + len_t]
        if int(tmp) == t:
            c += 1
print(c)

Submission status: Wrong Answer

Solution code:
si=input()
sa = []
sss = []

for i in range(5,len(si)+1):
    ss = int(si[(i-5):i])
    if ss % 2019 == 0 and ss <= 200000:
        sa.append(i)
        sss.append(ss)
    ss = int(si[(i-4):i])
    if ss % 2019 == 0 and ss <= 200000:
        sa.append(i)
        sss.append(ss)
#print(sa)
#print(sss)
print(len(sa))

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
if n < 4:
  quit()
l,r = 0,4
ans = [[[],[]] for _ in range(n+10)]
for i in range(4,8):
  l = 0
  while l+i <= n:
    if int(s[l:(l+i)])%2019 == 0:
      ans[l+1][0].append(l+i)
      ans[l+i+1][1].append(l+1)
    l += 1
final = 0
cnt = 1
for i in range(n+1):
  if ans[i][0] and ans[i][1]:
    cnt += 1
    final += cnt
  elif ans[i][0]:
    final += 1
    cnt = 1
print(final)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
# 1<=S<=200000
S = str(input()).rstrip()
# print(len(S))
count = 0
for i in range(len(S) - 3):
    # print(i)
    for j in range(i + 4, i + 7):
        if j > len(S):
            continue
        if int(S[i:j]) % 2019 == 0:
            # print(i, j, S[i:j])
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
num=input()
counter=0
for y in range(len(num)):
  for x in range(y):
    if int(num[x:y])%2019==0:
      counter=counter+1
print(counter-1)

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)
C = [0 for i in range(2019)]
C[0] = 1
now = 0
mod2019 = [1]
for i in range(2030):
    mod2019.append(mod2019[-1]*10%2019)
for i in range(N):
    now += int(S[-i-1])*mod2019[i%2019]
    now %= 2019
    C[now] += 1
ans = 0
for i in range(2019):
    ans += C[i]*(C[i]-1)//2
print(ans)

Submission status: Wrong Answer

Solution code:
S = input() # 1文字目,2文字目///

tar = 0
num = 0
len_s = len(S)
for i in range(101) :
  tar = 2019 * i
  if tar > int(S) :
    break
  tar_cnt = len(str(tar))
  for j in range(len_s-tar_cnt+1) :
    if S[j:j+tar_cnt] == str(tar):
  	  num += 1
print(num)

Submission status: Wrong Answer

Solution code:
S = input()

if int(S) < 2019:
    print(0)
    exit()

ans_list = ['2019', '4038', '6057', '8076', '10095', '12114', '14133', '16152', '18171', '20190', '22209', '24228', '26247', '28266', '30285', '32304', '34323', '36342', '38361', '40380', '42399', '44418', '46437', '48456', '50475', '52494', '54513', '56532', '58551', '60570', '62589', '64608', '66627', '68646', '70665', '72684', '74703', '76722', '78741', '80760', '82779', '84798', '86817', '88836', '90855', '92874', '94893', '96912', '98931', '100950', '102969', '104988', '107007', '109026', '111045', '113064', '115083', '117102', '119121', '121140', '123159', '125178', '127197', '129216', '131235', '133254', '135273', '137292', '139311', '141330', '143349', '145368', '147387', '149406', '151425', '153444', '155463', '157482', '159501', '161520', '163539', '165558', '167577', '169596', '171615', '173634', '175653', '177672', '179691', '181710', '183729', '185748', '187767', '189786', '191805', '193824', '195843', '197862', '199881']

count = 0
s_len = len(S)

for a in ans_list:
    l = len(a)
    i = 0
    if S.count(a) > 0:
        while True:
            if i+l > s_len:
                break 
            if S.count(a, i, i+l) > 0:
                count += 1
            i += 1

print(count)

Submission status: Wrong Answer

Solution code:
s=str(input())
count=0
for i in range(100):
 p=str(2019*i)
 for j in range(len(s)):
  if s[j:j+(len(p))]==p:
   count=count+1
print(count)

Submission status: Wrong Answer

Solution code:
matches = ['2019',
 '4038',
 '6057',
 '10095',
 '12114',
 '14133',
 '16152',
 '18171',
 '22209',
 '24228',
 '26247',
 '28266',
 '30285',
 '32304',
 '34323',
 '42399',
 '44418',
 '46437',
 '48456',
 '50475',
 '62589',
 '64608',
 '66627',
 '68646',
 '82779',
 '84798',
 '102969',
 '104988',
 '107007',
 '109026',
 '111045',
 '113064',
 '115083',
 '117102',
 '119121',
 '123159',
 '125178',
 '127197',
 '129216',
 '131235',
 '133254',
 '135273',
 '137292',
 '139311',
 '143349',
 '145368',
 '147387',
 '149406',
 '151425',
 '153444',
 '155463',
 '157482',
 '159501',
 '163539',
 '165558',
 '167577',
 '169596',
 '171615',
 '173634',
 '175653',
 '177672',
 '179691',
 '183729',
 '185748',
 '187767',
 '189786',
 '191805',
 '193824',
 '195843',
 '197862',
 '199881']

s = input()
len_s = len(s)
cnt = 0

for match in matches:
    len_m = len(match)
    i = len_m
    while i <= len_s:
        if match == s[i-len_m:i]:
            cnt += 1
        i += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
s = input("")
l = ['2019', '4038', '6057', '8076', '10095', '12114', '14133', '16152', '18171']
res = []
for i in l:
	b = s.find(i)
	while (b!= -1):
		res.append((b +1, b+ len(i)))
		b = s.find(i, b + 1)

print(len(res))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
S = input()
ans = 0
for i in range(len(S)-3):
    n = 0
    for j in range(i+3,len(S)+1):
        p = int(S[i:j])
        if p % 2019 == 0:
            ans += 1
            n = 0
        else:
            n += 1
        
        if n == 8:
            break

print(ans)

Submission status: Wrong Answer

Solution code:
S = str(input())
s = int(S)
n = len(S)
count = 0
for i in range(1,n+1):
    for j in range(i+4,n+1):
        si = s%10**(n-i+1)
        sij = si//10**(n-j)
        print(sij)
        if sij!= 0 and sij % 2019 == 0:
            count+=1

print(count)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for i in range(N)]
def dp2(ini, i, j): return [[ini]*i for i2 in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for i2 in range(j)] for i3 in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))
 
def main():
    S = input()
    N = len(S)
    tmp = 2019
    l = []
    cnt =0
    while True:
        if '0' not in str(tmp):
            l.append(str(tmp))
        tmp += 2019
        if tmp > 20190000:
            break
 
    cnt = 0
    for num in l:
        na = len(num)
        for i in range(0, N-na+1):
            if num == S[i:i+na]:
                cnt += 1
    print(cnt)
 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
S = str(input())
ans = 0

if len(S) <= 3:
    print(0)
else:   
    for i in range(len(S)-3):
        if int(S[i:i+3]) % 2019 == 0:
            ans+=1
    print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
pp = [1]
for i in range(n+1):
    pp.append(pp[i] * 10 % 2019)
a = [0] * (n+1)
for i in range(n):
    a[i+1] = a[i]*10 + int(s[i])
b = set()
for i in range(n+1):
    b.add((a[i]*pp[n-i])%2019)

print(n+1 - len(b))

Submission status: Wrong Answer

Solution code:


count = 0

import re
s = input()
div_num_origin = 2019
div_num = 2019
# count = 0
s_origin = s
while True:
    s = s_origin
    if div_num > 200000:
        break
    pattern = str(div_num) 
    while True:
        m = re.search(pattern, s)
        if m == None:
            break
        else:
            count += 1
            s = s[m.start()+1:]
    div_num += div_num_origin
print(count)

Submission status: Wrong Answer

Solution code:
s = str(input())
i = 0
ans = 0
while True:
    j = 0
    k = 5 + i
    i += 1
    if k > len(s) + 1:
        break
    while True:
        if k > len(s) + 1:
            break
        if int(s[j:k]) % 2019 == 0:
            ans += 1
        j += 1
        k += 1
print (str(ans))

Submission status: Wrong Answer

Solution code:
import numpy as np


# input the data
s = input()
m = len(s)
detecter = []
count = 0

for i in range(1, 100):
    detecter.append(str(i * 2019))

for i in range(len(detecter)):
    if (detecter[i] in s) == True:
        for j in range(m):
            detected = len(detecter[i])
            tmp = s.count(detecter[i], j, j + detected)
            if tmp > 0:
                count += tmp
print(count)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=(input())
num=[0]*len(N)

for i in range(len(N)-3):
    if int(N[i:i+4])%2019==0:
        num[i+3]+=1+num[i-1]

for i in range(len(N)-4):
    if int(N[i:i+5])%2019==0:
        num[i+4]+=1+num[i-1]

for i in range(len(N)-5):
    if int(N[i:i+6])%2019==0:
        num[i+5]+=1+num[i-1]
        
for i in range(len(N)-6):
    if int(N[i:i+7])%2019==0:
        num[i+6]+=1+num[i-1]


print(sum(num))

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque
import heapq
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
N = len(s)

data = [[] for i in range(10)]
ID = []

for i in range(1,1000):
  if i*2019 >= 200010:
    break
  else:
    tmp = str(i*2019)
    data[int(tmp[0])].append(tmp)

i = -1
while i != N:
  i += 1
  for j in range(i+1, N+1):
    num = s[i:j]
    f = 0
    for k in data[int(num[0])]:
      if k == num:
        ID.append((i+1,j))
        i = j - 1
        break
      elif k[:j-i] == num:
        f = 1
    else:
      if f == 1:
        continue
      else:
        break
#print(ID)


dd = []
cnt = 1
if len(ID) == 0:
  pass
else:
  for i in range(len(ID)-1):
    if ID[i][1] +1 == ID[i+1][0]:
      cnt += 1
    else:
      dd.append(cnt)
      cnt = 1
  else:
      dd.append(cnt)
#print(dd)

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

print(ans)

Submission status: Wrong Answer

Solution code:
from itertools import combinations
s = input()
d = {}
tmp = 0
i = 0
for char in s[::-1]:
    tmp += int(char) * pow(10, i, 2019)
    tmp %= 2019
    if tmp not in d:
        d[tmp] = 1
    else:
        d[tmp] += 1
    i += 1

result = 0
for num, v in d.items():
    if num == 0:
        result += v
        continue
    if v > 1:
        result += v * (v - 1) // 2

print(result)

Submission status: Wrong Answer

Solution code:
S=input()
N=len(S)
dp=[0 for i in range(N)]
check=[0 for i in range(N)]

List=[]
moji = ''
kireme=False
for i in range(N):
    moji+=S[i]
    dp[i]=dp[i-1]
    if len(moji)==9:
        moji=moji[1:]
    l=len(moji)
    for j in range(l):
        if int(moji[l-j-1:])%2019==0:
            List.append((i-j,i))
            check[i]+=1+check[i-j-1]
            dp[i]+=1
            if check[max(i-j-1,0)]:
                #check[i-j-1]+=1
                dp[i]+=check[i-j-1]
            
#print(List)
#print(check)
#print(dp) 
print(dp[N-1])

Submission status: Wrong Answer

Solution code:
tmp = input().split()
N = list(tmp)
p = 0
L = len(N[0])

for i in range(L-3):
    for j in range(L - i - 3):
        if int(N[0][i:i+j+1]) == 1 or int(N[0][i:i+j+1]) == 9:
            m = int(N[0][i:i+j+4])%2019
            if m == 0:
                p = p + 1

print(p)

Submission status: Wrong Answer

Solution code:
S = input()

ans = []
for left in range(len(S)):
    for right in range(left + 5, left + 50):
        temp = int(S[left:right])
        if temp % 2019 == 0:
            ans.append([left, right])

print(len(ans))

Submission status: Wrong Answer

Solution code:
s=input()
n=len(s)
k=2019
numMultiples = int(0)
for i in range(n):
    remainder = int(0)
    seenRemainders = {0}
    prefixesFound = int(0)
    for j in range(i,n):
        remainder = (10 * remainder + int(s[j])) % k
        if remainder == 0:
            prefixesFound+=1
        if remainder in seenRemainders:
            break
        seenRemainders.add(remainder)
    numMultiples += (prefixesFound * (prefixesFound + 1)) // 2
print(numMultiples)

Submission status: Wrong Answer

Solution code:
s=input()
if len(s)<=4:
  if int(s)%2019==0:
    print(1)
  else:
    print(0)
    
else:
  from collections import deque
  count=0
  for i in range(3,7):
    sub=deque()
    j=0
    while True:
      if len(sub)>=i+1:
        break
      sub.append(s[j])
      j+=1
    
    sub
    for k in range(i,len(s)):
      # print("k=",k)
      if k>i:
        sub.popleft()
        sub.append(s[k])
      tmp="".join(sub)
      # print("tmp=",tmp)
      if int(tmp)%2019==0:
        count+=1
        # print("ktkr")
  print(count)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

s = input()
length = len(s)

counter = 0

candidate = ['0000']
for i in range(1 + (length - 3) * 5):
    num = 2019 * (i + 1)
    candidate.append(num)
    # print(candidate)
for n in candidate:
    counter += s.count(str(n))

if s == '0' or s == '00' or s == '000':
    counter += 1
print(counter)

Submission status: Wrong Answer

Solution code:

S = str(input())
N = len(S)

slist = [int(S[i:j+1])%2019 for i in range(N-3) for j in range(i+3,N) ]


counter = slist.count(0)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=(input())
num=[0]*len(N)

for i in range(len(N)-3):
    if int(N[i:i+4])%2019==0:
        num[i+3]+=1+num[i-1]

for i in range(len(N)-4):
    if int(N[i:i+5])%2019==0:
        num[i+4]+=1+num[i-1]

for i in range(len(N)-5):
    if int(N[i:i+6])%2019==0:
        num[i+5]+=1+num[i-1]
        


print(num)
print(sum(num))

Submission status: Wrong Answer

Solution code:
def main():
  N = int(input()) # 1行, 単数

  S = str(N)
  count = 0
  for i in range(len(S) - 3):
    x = int(i)
    for j in range(int(i+3) , len(S)+1):
      y = int(j)
      A = int(S[x:y])
      if A % 2019 == 0:
        print(x ,y)
        count+=1
  print(count)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
s = input()
ans = 0
for i in range(len(s)):
	for j in range(i+3, len(s)):
		if math.ceil(int(s[i:j+1])) == math.floor(int(s[i:j+1])): 
			ans+=1
			#print(s[i:j+1])
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

list_2019_multiple = defaultdict(int)
N = 2019
while N < 20190000:
    if "0" not in list(str(N)):
        list_2019_multiple[str(N)] = 1
    N += 2019

S = input()
DP = [[0 for _ in range(2)] for _ in range(len(S))]
if len(S) < 5:
    print(0)
else:
    for i in range(4, len(S)):
        if list_2019_multiple[S[i - 4:i + 1]] == 1:
            if i > 4:
                DP[i][1] = 2 ** DP[i - 5][1]
            else:
                DP[i][1] += 1
        elif i >= 5 and list_2019_multiple[S[i - 5:i + 1]] == 1:
            if i > 5:
                DP[i][1] = 2 ** DP[i - 6][1]
            else:
                DP[i][1] += 1
        elif i >= 6 and list_2019_multiple[S[i - 6:i + 1]] == 1:
            if i > 6:
                DP[i][1] = 2 ** DP[i - 7][1]
            else:
                DP[i][1] += 1
        elif i >= 7 and list_2019_multiple[S[i - 7:i + 1]] == 1:
            if i > 7:
                DP[i][1] = 2 ** DP[i - 8][1]
            else:
                DP[i][1] += 1
        DP[i][0] = DP[i - 1][0] + DP[i - 1][1]
    print(sum(DP[-1]))

Submission status: Wrong Answer

Solution code:
import re

s = input()
ary = []
for i in range(10000):
  if not '0' in str(2019*i):
    ary.append(2019*i)

result = 0
for val in ary:
  result += len(re.findall(str(val), s))

print(result)

Submission status: Wrong Answer

Solution code:
S = list(input())
k = len(S)
m = 0
for i in range (k-3):
    j = 0
    while (j <= (k - i - 3 )):
        a = ''.join(S[j:j+i+4])
        s = int(a)
        if (s % 2019) == 0:
            m +=1
            j +=(i+3)
        else:
            j += ((i+4)//4)

print(m)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
count = 0
for d in range(3, n):
    for i in range(n - d):
        s_ = int(s[i:i+d])
        if s_ % 2019 == 0:
            count += 1
if count == 0:
    print(0)
else:
    print(count + 1)

Submission status: Wrong Answer

Solution code:
s = input()
baisu = []

n = 2019
while n <= 200000:
    baisu.append(str(n))
    n += 2019

ans = 0

for i in baisu:
    suffix = 0
    
    if i in s:
        tmp = ""
        for j in range(suffix, len(s)):
            tmp += s[j]
            suffix = j
            
            if i in tmp:
                ans += 1
                tmp = tmp[-1]
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
list = range(1, 100)
count = 0
for i in list:
    target = str(2019 * i)
    temp = S
    while True:
        find = temp.find(target)
        if find < 0:
            break
        else:
            count += 1
            temp = temp[find+1:]

print(count)

Submission status: Wrong Answer

Solution code:
S = input()
cnt = 0

length = len(S)
for i in range(0,len(S)-4):
  for j in range(i+4,i+4+30):
    if int(S[i:j+1]) % 2019 == 0 and j<length:
      cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
N=(input())
num=[0]*len(N)

for i in range(len(N)-3):
    if int(N[i:i+4])%2019==0:
        num[i+3]+=1+num[i-1]

for i in range(len(N)-4):
    if int(N[i:i+5])%2019==0:
        num[i+4]+=1+num[i-1]

for i in range(len(N)-5):
    if int(N[i:i+6])%2019==0:
        num[i+5]+=1+num[i-1]
        
for i in range(len(N)-6):
    if int(N[i:i+7])%2019==0:
        num[i+6]+=1+num[i-1]


print(num)
print(sum(num))

Submission status: Wrong Answer

Solution code:
def main(S):
    counta = 0
    for i in range(1, 100):
        num = str(i * 2019)
        if num in S:
            counta += 1
            index = S.find(num)
            new_S = S[index+1:]
            while num in new_S:
                counta += 1
                index = new_S.find(num)
                new_S = new_S[index+1:]
    print(counta)


if __name__ == '__main__':
    S = str(input())
    main(S)

Submission status: Wrong Answer

Solution code:
S = input()

count = 0
i = 0
flg = False
while i < len(S) - 4:
    j = i + 3
    while j < len(S):
        num = int(S[i:j + 1])
        if num > 0 and num % 2019 == 0:
            count += 1
            i = j
            # j のループを抜ける
            j = len(S)
            flg = True
        else:
            j += 1
    if not flg:
        i += 1

print(count)

Submission status: Wrong Answer

Solution code:
s = input()
len_s = len(s)
cnt = 0
for i in range(1,200000//2019 + 1):
    a = str(2019*i)
    len_a = len(a)
    for j in range(len_s - len_a + 1):
        cnt += s.count(a, j, j+len_a)
print(cnt)

Submission status: Wrong Answer

Solution code:
str=input()
gap_len=4
flag=0
count=0
if (len(str)==4):
    if(int(str)%2019==0):
        count+=1
for gap_len in range(4,len(str)):
    for i in list(range(len(str)-gap_len)):
        sub_str=str[flag:flag+gap_len]
        num=int(sub_str)
        if(num%2019==0):
            count+=1
        flag+=1
    flag=0
print(count)

Submission status: Wrong Answer

Solution code:

def main():
    S = input()
    # S = '1817181712114'

    isFinish = False
    count = 0
    
    bar = 0
    while not isFinish:
        isPath = False
        for j in range(bar+4, len(S)+1):
            # print(bar, j, int(S[bar:j]))
            t = int(S[bar:j]) % 2019

            if t == 0.0:
                # print('OK:', bar, j, int(S[bar:j]))
                bar = j-1
                count += 1
                isPath = True
                break
        if isPath == False:
            bar += 1
        # print(bar)
        if bar >= len(S)-2:
            isFinish = True
            break
    print(count)
        

main()

Submission status: Wrong Answer

Solution code:
si=input()
sa = []
sss = []

for i in range(5,len(si)+1):
    ss = int(si[(i-5):i])
    if ss % 2019 == 0 and ss <= 200000:
        sa.append(i)
        sss.append(ss)
#print(sa)
#print(sss)
print(len(sa))

Submission status: Wrong Answer

Solution code:
s = input()
print(s, len(s))
c = 0
for i in range(len(s) -4):
  for j in range(i + 4, len(s) + 1):
    if int(s[i:j]) % 2019 == 0:
      c += 1
print(c)

Submission status: Wrong Answer

Solution code:
def main():
    S = input()

    simo5 = set()
    for i in range(5,1000001):
        s = str(2019*i)
        if '0' not in s:
            simo5.add(s[-5]+s[-4]+s[-3]+s[-2]+s[-1])

    l = len(S)
    ans = 0
    for i in range(l-1,3,-1):
        tmp = ''.join([S[i-3],S[i-2],S[i-1],S[i]])
        if int(tmp)%2019 == 0:
            ans += 1
        else:
            tmp = ''.join([S[i-4],tmp])
            if tmp not in simo5:
                continue
            else:
                if int(tmp)%2019 == 0:
                    ans += 1
            for j in range(i-5,-1,-1):
                tmp = ''.join([S[j],tmp])
                print(tmp)
                if int(tmp)%2019 == 0:
                    print(tmp,'a')
                    ans += 1
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
s = input()
n = 2019

c = 0
for i in range(1, 1000):
    st = str(n*i)
    j = 0
    while j <= (len(s)-len(st)+1):
        if st in s[j:]:
            ind = s[j:].index(st)
            c+=1
            j = ind+j+1
        else:
            break
      
print(c)

Submission status: Wrong Answer

Solution code:
S = str(input())

ans = 0

for x in range(1, 100) :
  num = str(2019 * x)
  if num in S :
    for i in range(0, len(S) - 4) :
      if num == S[i:i + len(num)] :
        ans += 1
    
print(ans)

Submission status: Wrong Answer

Solution code:

S = str(input())
N = len(S)

slist = [int(S[i:j+1])%2019 for i in range(N-3) for j in range(i+3,N) ]



counter = slist.count(0)

Submission status: Wrong Answer

Solution code:
def count(text, part):
    return sum(text.startswith(part, i) for i in range(len(text)))
ans=0
s=input()
l=[str(2019*i) for i in range(1,100)]
for i in l:
  ans+=count(s,i)
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
ans = 0

for i in range(len(s)):
  for j in range(len(s)):
    a = s[i:i+j+2]
    if int(a) % 2019 == 0 and len(a) >= 4:
      ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import re

S = str(input())

def count_o(sub, string):
    # via https://www.geeksforgeeks.org/python-count-overlapping-substring-in-a-given-string/
    count = 0
    start = 0
    while start < len(string):
        pos = string.find(sub, start)
        if pos != -1:
            start = pos + 1
            count += 1
        else:
            break
    return count

count = 0
for i in range(1, 100):
    j = str(i * 2019)
    if j not in S:
        continue
    count += count_o(j, S)

print(count)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
N = int(input())
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

S = input().rstrip()

counter = 0
for l_index in range(len(S) - 4):
    atama = int(S[l_index:l_index+2])
    if atama % 2 != 0:
        continue
    else:
        r_index = 5
        while True:
            saigo = l_index + r_index
            if saigo > len(S):
                break
            kouho = int(S[l_index:saigo])
            if kouho % 2019 == 0:
                counter += 1
                break
            r_index += 1


print(counter)

Submission status: Wrong Answer

Solution code:
import re

s = input()

l = ['0'] * (200000 // 2019)
ans = 0

for i in range(len(l)):
  w = str(2019 * (i+1))
  w_l = len(w)
  #print(w)
  for j in range((len(s)-w_l+1)):
    t = s[j:(j+w_l)]
    if w == t:
      ans += 1
      # print(w)


print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
s_num = int(s)
len_s = len(s)
list=[0 for x in range(len_s+1)]
for i in range(len_s-1,-1,-1):
    for j in range(1,min(30,len_s-i+1)):
        if int(s[i:i+j])%2019==0:
            list[i]=list[i+j]+1
print(sum(list))

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
if n < 4:
  quit()
l,r = 0,4
ans = [[[],[]] for _ in range(n+3)]
for i in range(4,8):
  l = 0
  while l+i <= n:
    if int(s[l:(l+i)])%2019 == 0:
      ans[l+1][0].append(l+i)
      ans[l+i+1][1].append(l+1)
    l += 1
for l in ans:
  print(l)
final = 0
cnt = 1
for i in range(n+1):
  if ans[i][0] and ans[i][1]:
    cnt += 1
    final += cnt
  elif ans[i][0]:
    final += 1
    cnt = 1
print(final)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
c = 0
for i in range(n-3):
    for j in range(i+3,n):
        if not int(s[i:j])%2019:
            c += 1
print(c)

Submission status: Wrong Answer

Solution code:
import re
S=input()

x=[i for i in range(1,100)]
x=map(lambda i:str(i*2019),x)


ans=0

for i in x:
    t=len(re.findall("(?={})".format(i),S))
    ans+=t

print(ans)

Submission status: Wrong Answer

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
S = input()
Slen = len(S)

if len(S)<=3:
    print(0)
    exit()

@lru_cache(maxsize=10000)
def check(n):
    if n%2019 == 0:
        return True
    else:
        return False

ans = 0
for i in range(Slen - 4 + 1):
    num_s = 4
    # for num_s in range(4,Slen+1-i):
    while num_s < Slen+1-i:
        num = int(S[i:i+num_s])
        if check(num):
            ans += 1
            num_s += 4
        else:
            num_s += 1
        print(num,num_s,ans)

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Wrong Answer

Solution code:
s = input()
ls = [str((i+1) * 2019) for i in range(int(200000 // 2019))]
c = 0
for i in ls:
    if s.count(str(i)) > 0:
        for pos in range(len(s)):
            if s[pos:].startswith(i):
                c += 1
print(c)

Submission status: Wrong Answer

Solution code:
s=input()
b=len(s)
x=0
for j in range(b-3):
    for i in range(b-j-4):
        a= int(s[j:j+i+5])
        if a % 3 ==0:
            if a%2019:
                x+=1
        else:
            continue
print(x)

Submission status: Wrong Answer

Solution code:
S = str(input())

baisu = [str(2019 * i) for i in range(1, 101) if '0' not in str(2019 * i)]
cnt=0
for i in baisu:
    if i in S:
        for j in range(0, len(S)-len(i)+1):
            if i==[S[j:j+len(i)]][0]:
                cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
s = str(input())
length = len(s)
count = 0
first = [1, 2, 4, 6, 8]
for i in range(length - 2):
  if int(s[i])%2 in first:
    for j in range(i+3, length + 1):
      if int(s[i:j])%2019 == 0:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import sys
s = input()
l = len(s)
ans = 0
if s == "2019":
    print(1)
    sys.exit()
for i in range(1, l -3):
    for j in range(4, l +1):
        string_j = int(s[:j])
        string_i = int(s[:i]) 
        if (string_j - string_i) % 2019 == 0:
            ans += 1

print(ans // 2)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    L = list(map(str, range(2019, 2 * (10 ** 5), 2019)))
    n = len(s)

    cnt = 0
    start = 0
    for i in range(n + 1):
        for l in L:
            if l in s[start: i + 1]:
                cnt += 1
                start = i - 3
                break

    print(cnt)


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import deque
import heapq
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
N = len(s)

data = [[] for i in range(10)]
ID = []

for i in range(1,1000):
  if i*2019 >= 200010:
    break
  else:
    tmp = str(i*2019)
    data[int(tmp[0])].append(tmp)

i = -1
while i != N:
  i += 1
  for j in range(i+1, N+1):
    num = s[i:j]
    f = 0
    for k in data[int(num[0])]:
      if k == num:
        ID.append((i+1,j))
        i = j - 1
        break
      elif k[:j-i] == num:
        f = 1
    else:
      if f == 1:
        continue
      else:
        break

dd = []
cnt = 1
if len(ID) == 0:
  pass
else:
  for i in range(len(ID)-1):
    if ID[i+1][1] +1 == ID[i][0]:
      cnt += 1
    else:
      dd.append(cnt)
      cnt = 1
  else:
      dd.append(cnt)
#print(dd)

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

print(ans)