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:
import sys
S = sys.stdin.readline()

N = len(S)

count = 0

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

print(count)

Submission status: Wrong Answer

Solution code:
s = input()
i = 2019
an = 0
while int(i) <= 200000:
    c = str(i)
    if c in s:
        a = [x for x in range(len(s)) if s.startswith(c, x)] 
        an += len(a)
    i += 2019
print(an)

Submission status: Wrong Answer

Solution code:
def c(n):
  return (n*(n-1)//2)
  
S = int(input())
s = str(S)
a = len(s)
enbas = [0]*(a+1)
puiss = 1
for i in range(a):
  enbas[i]=((int(s[a-i-1])*puiss+enbas[i-1])%2019)
  puiss=(puiss%2019)*10
enbas.sort()
print(enbas)
compte = 0
i = 0
avant = 0
for n in range(a+1):
  if avant==enbas[n]:
    i+=1
  else:
    compte+=c(i)
    avant = enbas[n]
    i = 1
print(compte)

Submission status: Wrong Answer

Solution code:
S = input()
count = 0
for i in range(len(S)):
  if int(S[i]) <= 0:
    if int(S[i+1]) <= 1:
      for j in range(i+1,i+8):
        if int(S[i:j]) % 2019 == 0 and int(S[i:j]) != 0:
          count = count + 1
          if j >= len(S):
            break
    if int(S[i+1]) >= 2:
      if int(S[i+1:i+7]) == 200000:
        for j in range(i+1,i+8):
          if int(S[i:j]) % 2019 == 0 and int(S[i:j]) != 0:
            count = count + 1
            if j >= len(S):
              break
      else:
        for j in range(i+1,i+7):
          if int(S[i:j]) % 2019 == 0 and int(S[i:j]) != 0:
            count = count + 1
            if j >= len(S):
              break
  if int(S[i]) <= 1:
    for j in range(i+1,i+7):
      if int(S[i:j]) % 2019 == 0 and int(S[i:j]) != 0:
        count = count + 1
        if j >= len(S):
          break
  if int(S[i]) >= 2:
    if int(S[i:i+6]) == 200000:
      for j in range(i+1,i+7):
        if int(S[i:j]) % 2019 == 0 and int(S[i:j]) != 0:
          count = count + 1
          if j >= len(S):
            break
    else:
      for j in range(i+1,i+6):
        if int(S[i:j]) % 2019 == 0 and int(S[i:j]) != 0:
          count = count + 1
          if j >= len(S):
            break
print(count)

Submission status: Wrong Answer

Solution code:
S = input()
count = 0
flg = False
for j in range(3, len(S)+1):
    if flg:
        j += 2
    for i in range(j-3):
        s = int(S[i:j])
        if s % 2019 == 0:
            count += 1
            if s % 2 == 0:
                flg = True
print(count)

Submission status: Wrong Answer

Solution code:
str = input()
ans = 0
if int(str) % 2019 == 0: ans += 1
for x in range(len(str) - 4):
    if x + 4 < len(str) and int(str[x : x + 5]) % 2019 == 0: ans += 1
    if x + 5 < len(str) and int(str[x : x + 6]) % 2019 == 0: ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
for i in range(20000000):
  a = 0

print(1)

Submission status: Wrong Answer

Solution code:
S = str(input())
N = len(S)

ans = 0
for i in range(N-4):
    for j in range(i+3,N):
        if j == i+3:
            temp = int(S[i:j+1])
        else:
            temp = temp*10 + int(S[j])
        if temp%2019 == 0:
            ans += 1
            print(temp)

print(ans)

Submission status: Wrong Answer

Solution code:
s = str(input())
ls = [2019*i for i in range(1, 30)]
n = 0
for item in ls:
    if str(item) in s:
        n += 1
print(n+1)

Submission status: Wrong Answer

Solution code:
def main():
    s=list(map(int,input()))
    modpow=[1]*len(s)
    for i in range(1,len(s)):
        modpow[i]=(modpow[i-1]*10)%2019
    ans=0
    res=[0]*len(s)
    res[0]=s[-1]%2019
    for i in range(1,len(s)):
        res[i]=(modpow[i]*s[len(s)-1-i]+res[i-1])%2019
    res.sort()
    res.append(2019)
    cnt=0
    for i in range(len(s)-1):
        if res[i]==0:
            ans+=1
        elif res[i]==res[i+1]:
            cnt+=1
        else:
            ans+=cnt
            cnt=0
    print(ans)
if __name__=="__main__":
    main()

Submission status: Wrong Answer

Solution code:
S = input()
l = len(S)
ans=0
for i in range(l-4):
    for j in range(i+4,i+7):
        m = int(S[i:j])
        if m%673 ==0:
            if m%3 ==0:
                ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
a, lists, count = str(input()), [], 0
for x in a:
    if x == '0':
        count += 1
for i in range(1, len(a)-3):
     lists.append(a[i]+a[i+1]+a[i+2]+a[i+3])
for i in range(1, len(a)-4):
    lists.append(a[i]+a[i+1]+a[i+2]+a[i+3]+a[i+4])
for i in range(1, len(a)-5):
    lists.append(a[i]+a[i+1]+a[i+2]+a[i+3]+a[i+4]+a[i+5])
for i in range(1, len(a)-6):
    lists.append(a[i]+a[i+1]+a[i+2]+a[i+3]+a[i+4]+a[i+5]+a[i+6])
for i in range(1, len(a)-7):
    lists.append(a[i]+a[i+1]+a[i+2]+a[i+3]+a[i+4]+a[i+5]+a[i+6]+a[i+7])
#list2 = [2019, 4038, 6057, 8076, 10095, 12114, 14133, 16152, 18171, 20190]
#for x in list2:
 #   if str(x) in lists:
  #      count += 1
for x in lists:
    if int(x) % 2019 == 0:
        count += 1
print(count)
print(lists)

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)
        if sij % 2019 == 0:
            count+=1
            i+=4
            j+=4

print(count)

Submission status: Wrong Answer

Solution code:
s = input() 
n = len(s)
sum = 0

for i in range(5):
    num5 = []
    sum_num = 0
    serict = 0
    j = 0
    while 5*(j+1)+i <= n:
        num = int(s[5*j+i:5*(j+1)+i])
        if num % 2019 == 0:
            num5.append(1)
        else:
            num5.append(0)
        j+=1
    # print(num5)
    for j in range(len(num5)):
        if num5[j] == 1:
            sum_num+=1
            serict+=1
        else:
            if n > 1:
                sum_num += int(serict*(serict-1)/2)

            serict = 0
    
    if n > 1:
        sum_num+= int(serict*(serict-1)/2)
    
    sum += sum_num

print(sum)

Submission status: Wrong Answer

Solution code:
s=input()
multiples = list(map(str, [2019*i for i in range(1, 100)]))
length = len(s)
ans = 0
option = [4,5,6]
for leng in option:
    for i in range(length-leng+1):
        if s[i:i+leng] in multiples:
            ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
S=int(s)
st=0
sums=0
for i in range(99):
    a=str(2019*(i+1))
    for j in range(len(s)-len(a)+1):
        if int(s[j:j+len(a)])-int(a)==0:
            st=st+1
        else:
            g=0
            
            
            
    
print(st)

Submission status: Wrong Answer

Solution code:
S = input()
intS = list(map(int, S))
n = len(S)

l = 1
res = 0
i = 0
while i < n-3:
    
    x = int(S[i:i+3])
    l += 1
    cnt = 0
    for j in range(i+3, n):
        x *= 10
        x += intS[j]
        x %= 2019
        if x == 0:
            cnt += 1
            l = j
    
    res += (cnt+1)*cnt//2
    
    i = l

print(res)

Submission status: Wrong Answer

Solution code:
n = str(input())

i = 0
def dfs(st, ed):
    global i
    bonus = 0
    while ed <= num:
        if len(n[st:ed]) > 7:
            break
        elif int(n[st:ed]) % 2019 == 0:
            i += 1 + bonus
            st = ed + 1
            ed = ed + 4
            bonus +=1
        ed += 1

num = len(n)
for _ in range(num):
    if _ + 5 <= num:
        dfs(_, _+5)
    else:
        break
print(i)

Submission status: Wrong Answer

Solution code:
aaa = input()

bbb = [2019*i for i in range(10000)]

k = 0
ans = 0
for a in bbb:
    k = bbb.count(str(a))
    ans += k

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
cnt = 0
ln = len(s)+1

for i in range(4, ln):
    print(i)
    lns = ln-i
    for j in range(lns):
        print('in',j,j+i,'->',int(s[j:j+i]))
        if sum([int(x) for x in s[j:j+i]]) % 3 == 0:
            if int(s[j:j+i])%2019 == 0:
                cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math
import functools
import bisect

s = input()
li = [0]
c = 2019
for i in range(1,110):
    li.append(c*i)
li.sort()
cnt = 0
cnt = s.count("0")
for i in range(len(s)-3):
    c = ""
    for j in range(4):
        c += s[i+j]
    if int(c) in li:
        cnt+=1
    
for i in range(len(s)-4):
    c = ""
    for j in range(5):
        c += s[i+j]
    if int(c) in li:
        cnt+=1
for i in range(len(s)-5):
    c = ""
    for j in range(6):
        c += s[i+j]
    if int(c) in li:
        cnt+=1
    
print(cnt)

Submission status: Wrong Answer

Solution code:
N = input()
a = 0

for i in range(len(N)):
  if N[i] == 0:
    continue
  for j in range(len(N)):
    if i > j:
      continue
    if int(N[i:j + 1]) == 0:
      continue
    #print(N[i:j + 1])
    if int(N[i:j + 1]) % 2019 == 0:
      a += 1
      print(N[i:j + 1])

print(a)

Submission status: Wrong Answer

Solution code:
s = input()
n = len(s)
sums_from_first_mod = [0] * (n+1)
for i in range(1,n+1):
    sums_from_first_mod[i] = (sums_from_first_mod[i-1] + int(s[i-1])) % 3
# print(sums_from_first_mod)
ind0 = [i for i, x in enumerate(sums_from_first_mod) if x == 0]
ind1 = [i for i, x in enumerate(sums_from_first_mod) if x == 1]
ind2 = [i for i, x in enumerate(sums_from_first_mod) if x == 2]
indices = [ind0, ind1, ind2]    
print(indices)
cnt = 0
for num in range(3):
    for i in indices[num]:
        for j in indices[num]:
            if j >= i+4:
                if int(s[i:j]) % 673 == 0:
                    cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
str = input()
ans = 0
for x in range(len(str) - 4):
    if x + 4 < len(str) and int(str[x : x + 5]) % 2019 == 0: ans += 1
    if x + 5 < len(str) and int(str[x : x + 6]) % 2019 == 0: ans += 1
    if x + 6 < len(str) and int(str[x : x + 7]) % 2019 == 0: ans += 1
    if x + 7 < len(str) and int(str[x : x + 7]) % 2019 == 0: ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)

l = [str(i * 2019) for i in range(1, 1000)]
l.sort()

end = [-1] * N


from bisect import *


for i in range(N):
    for j in range(i + 4, i + 8):
        if j > N:
            break

        # print(bisect_left(l, S[i:j]))


        index = bisect_left(l, S[i:j])
        if 0 <= index < len(l) and l[index] == S[i:j]:

            # にぶたんで

            # if S[i:j] in l:
            end[i] = j


ans = 0

# print(end)

for i in range(N):
    a = 1
    j = end[i]
    while j != -1:
        a += 1
        if j == N:
            break
        j, end[j] = end[j], -1

    ans += a * (a - 1) // 2

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

s = input()
l = Counter()
sub=""
for i in s:
    sub+=i
    l[int(sub)%2019]+=1

res = 0
for key, val in l.most_common():
    res += val*(val-1)//2

res+=l[0]
print(res)

Submission status: Wrong Answer

Solution code:
for i in range(2000000):
  a = 0
  
print(0)

Submission status: Wrong Answer

Solution code:
S = input()
ans = 0
k = 0
l = 3

for i in range(k,len(S)):
    for j in range(l,len(S)):
        if i!=j and i <= j:
            if int(S[i:j+1]) % 2019 == 0:
                ans+=1
                k = i
                l = j
                print(i,j)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    s = input().rstrip()

    s_nums = list(range(len(s)+1))

    ans = 0

    li = [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]

    for l in li:
        s_i = s.find(str(l))
        if s_i == -1:
            continue
        else:
            s_c = 0
            i = 0
            while s_i > -1:
                i += s_i+1
                s_c += 1
                s_i = s[i:].find(str(l))

            ans += s_c

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
S = input()

count = 0
tmp = 0
for i in range(len(S)-4):
    for j in range(i+4, i+7):
        s = int(S[i:j])
        if s == tmp:
            tmp = s
            continue
        if s % 2019 == 0:
            count += 1
        tmp= s
            
print(count)

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)

print(re.findall('('+'|'.join(map(str, ary))+')+', s))

Submission status: Wrong Answer

Solution code:
S=input()
S1=int(S)
#print(len(S))
S_count=len(S)
sum=0
sum1=0
ii=0
jj=4
SSSS=int(S_count)
for i in range(S_count):
  sum1+=i
#print(sum1)
for i in range(sum1):
  if ii==int(S_count-3):
    break
  SS=S[ii:jj]
  print(SS)
  SSS=int(SS)
  if SSS%2019==0:
    sum+=1
  jj+=1
  if jj==int(S_count+1):
    ii+=1
    if ii>=4:
      jj=ii+1
    else:
      jj=4
  
print(sum)

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 % 2019 == 0:
            count+=1
            i+=4
            j+=4

print(count)

Submission status: Wrong Answer

Solution code:
# import re
S = input()
cnt = 0

multiple = [2019]
i = 2
while multiple[-1] < 200000:
    multiple.append(2019 * i)
    i += 1
multiple.pop()
multiple = [str(i) for i in multiple]

# cnt = len(re.findall('18171', S))
# print(cnt)

for i in range(len(S)):
    for j in multiple:
        if j in S[i:i+len(j)]:
            cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
    count = 0
    a = input()
    for i in range(1,101):
        b=str(2019*i)
        for j in range(len(a)-len(b)+1):
            if(a[j:j+len(b)]==b):
                count +=1
    print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
#1~9をn桁目としたとき、2019で割ったあまりを求める
m = []
s = list(s)
s = list(map(int,s))

#j文字目が1桁目であるとき、条件を満たすiの数を考える


temp = []
d_mod = lambda x:x*10%2019
ret = 0
for i in s:
    temp = list(map(d_mod,temp))
    temp = list(map(lambda x:(x+i)%2019,temp))
    temp.append(i)
    ret+=temp.count(0)
    print(ret)
print(ret)

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)

ans=0
prev = float("inf")
for i in range(N):
    prev = float("inf")
    for j in range(i+4,N+1):
        tmp = int(S[i:j])%2019
        if tmp>prev:
            break
        if int(S[i:j])%2019==0:
            #print("\ti,j=>",i,j,S[i:j],int(S[i:j])//2019)
            ans+=1
        prev = tmp
print(ans)

#ans = 0
#for i in reversed(range(1,N+1)):
#    for d in range(4,N):
#        if i-d<0:
#            break
#        print("i,j,S=>",i,j,S[i-d:i],int(S[i-d:i])%2019)
#        if int(S[i-d:i])%2019==0:
#            print("\t find i,j,S=>",i,j,S[i-d:i])
#            ans+=1
#print(ans)

Submission status: Wrong Answer

Solution code:
s = str(input())
 
ans = 0
len_s = len(s)
ans_pos = []
str_pos = {}
end_pos = {}
for i in range(4,9):
    for j in range(len_s):
        if j+i > len_s :
            break
        if int(s[j:j+i]) % 2019 == 0:
            ans +=1
            str_pos[j] = 0
            end_pos[j+i-2]= 0
            #ans_pos.append([j,j+i-1])

for st in str_pos.keys():
    if st in end_pos.keys():
        ans += 1


print(ans)

Submission status: Wrong Answer

Solution code:
def s2019(n):
    print(n)
    return n&2^0 and n&2^1 and n&2^5 and n&2^6 and n&2^7 and n&2^8 and n&2^9 and n&2^10

def main():
    S = input()
    cnt = 0
    for i in reversed(range(len(S)+1)):
        for j in reversed(range(i+3, len(S)+1)):
            if int(S[i:j]) % 2019 == 0:
            # print(i,j)
            # if s2019(int(S[i:j])):
                print(i,j,int(S[i:j]))
                cnt += 1
            # else:
            #     break
    print(cnt)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    S = sys.stdin.readline()[:-1]

    # S = input()
    int_S = int(S)
    N = len(S)
    cnt = 0
    pos_l = 0
    pos_r = 0


    while (True):
        pos_r +=  + 1
        
        if (pos_r < N):
            tmp = int(S[pos_l: pos_r + 1])
            if (tmp % 2019 == 0):
                cnt += 1
                pos_l = pos_r
        else:
            pos_l += 1
        
        if (pos_l >= N):
            break


    print(cnt)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N = str(input())

#N = str(14282668646)

count = 0
lenN = len(N)+1
for i in range(0, lenN):
#    t = i
    for j in range(i+5, min(i+9, lenN)):

        number = int(str(N[i:j]))
        if number%2019 == 0:
            count +=1

print (count)

Submission status: Wrong Answer

Solution code:
S = input()
if len(S) == 4:
    if int(S) % 2019 == 0:
        print(int(S)//2019)
    else:
        print(0)
else:
    ans = [1 for i in range(len(S)-4) for j in range(i+4,len(S)) if int(S[i:j])%2019==0]
    print(sum(ans)+1)

Submission status: Wrong Answer

Solution code:
aaa = input()

bbb = [2019*i for i in range(10000)]

k = 0
ans = 0
for a in bbb:
    k = bbb.count(a)
    ans += k

print(ans)

Submission status: Wrong Answer

Solution code:
#ABC 164D

def count(text, part):
    return sum(text.startswith(part, i) for i in range(len(text)))

s = str(input())
#s = '1817181712114'
#s = '14282668646'

cnt = 0

for i in range(1, 100):
    cnt += count(s, str(2019*i))

print(cnt)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

S = read_str()
l = len(S)

def solve():
    ans = 0
    i = 0
    while i < l - 3:
        for j in range(i + 4, l + 1):
            if int(S[i:j]) % 2019 == 0:
                ans += 1
                i += 3
        i += 1
    return ans

if __name__ == "__main__":
    print(solve())

Submission status: Wrong Answer

Solution code:
import collections
import sys
import numpy as np
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
MOD = 10**9+7
import itertools
import math
import functools
import bisect

s = input()
li = [0]
c = 2019
for i in range(1,110):
    li.append(c*i)
li.sort()
cnt = 0
for i in range(len(s)-3):
    c = ""
    for j in range(4):
        c += s[i+j]
    if int(c) in li:
        cnt+=1
    
for i in range(len(s)-4):
    c = ""
    for j in range(5):
        c += s[i+j]
    if int(c) in li:
        cnt+=1
for i in range(len(s)-5):
    c = ""
    for j in range(6):
        c += s[i+j]
    if int(c) in li:
        cnt+=1
    
print(cnt)

Submission status: Wrong Answer

Solution code:
S = input()
num = int(S[0])
check = 1
count = 0
for i in range(len(S)):
    while num <= 200000:
        if num != 0:
            if num % 2019 == 0 :
                count += 1
            #print(num)
        try:
            num = num*10 + int(S[i+check])
        except:
            break
        check += 1
            #print(count)
    try:
        num = int(S[i+1])
    except:
        break
    check = 1
print(count)

Submission status: Wrong Answer

Solution code:
s=input()
n=len(s)
count=0
#for j in range(n-3):
j=0
while j<n-3:
	i=4
	while(i<n-j+1):
	#for i in range(4,n+1-j):
		nu = int(s[j:i+j])
		#print(nu) 
		if nu%2019==0:
			count+=1
			j+=3
			break

		i+=1
	j+=1
print(count)

Submission status: Wrong Answer

Solution code:
import sys

s = str(input())
tisa = []
for i in range(1,1000000):
  ww = str(2019*i)
  if '0' not in ww:
    tisa.append(ww)
#ok
#print(s)
#print(tisa)
#print(len(tisa))
#重複　count methodは無理
ans = 0
for c in tisa:
  for i in range(0,len(s)-len(c)+1,4):
    if s[i:i+len(c)]==c:
      ans += 1

      
  

print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
len_s = len(s)

ans = 0
i = 0
l = 0

while l < len_s:
    l += 1
    for y in range(i, len_s):
        if int(s[i:y+1]) % 2019 == 0:
            ans += 1
            i = y
            l = y
            break
    else:
        if ans == 0:
            i += 1
        else:
            break
print(ans)

Submission status: Wrong Answer

Solution code:
S = list(input())
l = len(S)

cnt = sum([1 for i in range(l-3) 
          for j in range(i+3,l) 
          if int(''.join(S[i:j])) % 2019 == 0]
         )
print(cnt)

Submission status: Wrong Answer

Solution code:
N = input()
a = [2019 * i for i in range(1,101)]
ans = 0
for i in a:
    st = N
    d = str(i)
    if st.find(d) != -1:
        while True:
            if st.find(d) != -1:
                ans += 1
                st = st[st.find(d)+1:]
            else:
                break
print(ans)

Submission status: Wrong Answer

Solution code:

S = input()

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

    c = 0
    i = 0
    while i < len(S)-3:
        for j in range(i+3, len(S)+1):
            if int(S[i:j])%2019 == 0:
                c += 1
                i = j-2
                break
        i += 1
        
    print(c)

Submission status: Wrong Answer

Solution code:
n=int(input())
S=str(n)
a=len(S)
ans=0
for i in range(0,a-3):
   for j in range(i+4,a+1):
      ss=int(S[i:j])
      if ss<2019:
         continue
      else:
         while len(str(ss))>5:
            ss=int(str(ss)[:-1]) - (int(str(ss)[-1])*2)
      if ss%2019==0:
         ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
S = str(input())
S_int = int(S)

count = 0
  
if S_int < 2019:
  print(0)
else:
  for i in range(len(S)-3):
    for j in range(i+4,len(S)):
      test = S[i:j]
      print(test)
      mojiretsu = ''.join(test)
      test_int = int(mojiretsu)
      if test_int % 2019 == 0:
        count = count + 1

print(count)

Submission status: Wrong Answer

Solution code:
from sys import stdin

S = stdin.readline().rstrip()
N = len(S)
Sp = S

res_map = [0 for _ in range(N)]

aa_list2 = [1]
for i in range(1,N):
    aa_list2.append((aa_list2[i-1]*10)%2019)


res_map[N-1] = int(S[N-1])
index=1
for i in range(N-2,-1,-1):
    res_map[i] = (int(S[i])*aa_list2[index] + res_map[i+1])%2019
    index+=1

res_map.sort()
temp_num=res_map[0]
index=1
tot = 0

for i in range(1,N):
    if temp_num==res_map[i]:
        index+=1
        continue
    else:
        if temp_num==0:
            tot += index*(index+1)/2
        elif index>1:
            tot += index*(index-1)/2
            #tot += index/2
        index=1
        temp_num=res_map[i]





print(int(tot))

Submission status: Wrong Answer

Solution code:
s = input().strip()
n=len(s)

ans=0
last=-2
for i in range(n-3):
    for j in range(i+3,i+5):
        if j>=n:
            continue
        if int(s[i:j+1]) % 2019==0:
            ans+=1
            if i == last+1:
                ans += 1
            last = j
print(ans)

Submission status: Wrong Answer

Solution code:
N = str(input())

#N = str(14282668646)

count = 0
lenN = len(N)+1
for i in range(0, lenN):
#    t = i
    for j in range(i+5, min(i+8, lenN)):
#        print (N[i:j])
#        print (i, j)
        number = int(str(N[i:j]))
        if number%2019 == 0:
            count +=1


print (count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
# print(S)

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

count = 0
i = 0
while i < len(S) - 3:
# for i in range(0, (len(S) - 3)):
    # print(i)
    found = False

    for j in range(i + 3, len(S)):
        number = int(S[i:j + 1])
        if number % 2019 == 0:
            # print(number, i, j)
            count += 1
            found = True
            break

    if found:
        i = j
    else:
        # i += 1
        break

print(count)

# for i in range(1, 101):
#     print(i, 2019 * i)

# 26247
# 2624
# 26247


# 1 2019
# 2 4038
# 3 6057
# 4 8076
# 5 10095
# 6 12114
# 7 14133
# 8 16152
# 9 18171
# 10 20190
# 11 22209
# 12 24228
# 13 26247
# 14 28266
# 15 30285
# 16 32304
# 17 34323
# 18 36342
# 19 38361
# 20 40380
# 21 42399
# 22 44418
# 23 46437
# 24 48456
# 25 50475
# 26 52494
# 27 54513
# 28 56532
# 29 58551
# 30 60570
# 31 62589
# 32 64608

Submission status: Wrong Answer

Solution code:
import functools
def solve():
    s = int(input())
    t = [int(x) for x in list(str(s))]

    l = []
    for i in range(1, 1000):
        num = [int(x) for x in list(str(i*2019))]
        if 0 not in num:
            l.append(num)

    cnt = 0
    n= len(t)
    for i in range(len(l)):
        m = len(l[i])
        for j in range(n-m+1):
            if l[i] == t[j:j+m]:
                    cnt += 1

    return cnt
    
print(solve())

Submission status: Wrong Answer

Solution code:
s = input()
count = 0
l = len(s)
for i in range(l-4):
    if l - i>=9:
        tmp = int(s[i:i+9])
        if tmp%2019==0:
            count +=1
    if l - i>=8:
        tmp = int(s[i:i+8])
        if tmp%2019==0:
            count +=1
    if l - i>=7:
        tmp = int(s[i:i+7])
        if tmp%2019==0:
            count +=1
    if l - i>=6:
        tmp = int(s[i:i+6])
        if tmp%2019==0:
            count +=1
    if l - i>=5:
        tmp = int(s[i:i+5])
        if tmp%2019==0:
            count +=1
    tmp = int(s[i:i+4])
    if tmp%2019==0:
        count +=1
print(count)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline

def main():
    s = input().rstrip()

    s_nums = list(range(len(s)+1))

    ans = 0

    li = [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]

    for l in li:
        s_i = s.find(str(l))
        if s_i == -1:
            continue
        else:
            s_c = 0
            i = 0
            while s_i > -1:
                i += s_i+1
                s_c += 1
                s_i = s[i+1:].find(str(l))

            ans += s_c

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    S =     _in[0]   # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    len_S = len(S)
    memo = set()
    cnt = 0
    for i in range(len_S):
        for j in range(i+3,len_S):
            print(int(S[len_S-j-1:len_S-i]))
            if j == i+3:
                mod = int(S[len_S-j-1:len_S-i])%3
            else:
                mod = (mod+int(S[len_S-j-1]))%3
            if mod == 0:
                _ = int(S[len_S-j-1:len_S-i])
                if _ in memo:
                    cnt += 1
                elif _%2019==0:
                    cnt += 1
                    memo.add(_)
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
s = input()
n = len(s)
cs = [0] * (n + 1)
for i, x in enumerate(s):
    cs[i + 1] = cs[i] + int(x)
ans = 0
i = 0
while i < n:
    for j in range(i + 3, n + 1):
        if (cs[j] - cs[i]) % 3 != 0:
            continue
        k = int(s[i:j])
        if k % 2019 == 0:
            ans += 1
            i = j - 1
    i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

s = input()

if len(s) < 4:
    print(0)
    sys.exit

count = 0

# start = 0
# stop = 1

# while(True):
#     num = int(s[start:stop])
#     # print(num)
    
#     if num % 2019 == 0:
#         print(f'{start + 1} {stop}')
#         count += 1
    
#     if stop + 1 > len(s):
#         break
#     stop += 1
    
# while(True):
#     num = int(s[start:stop])
#     # print(num)
    
#     if num % 2019 == 0:
#         print(f'{start + 1} {stop}')
#         count += 1
    
#     start += 1
#     if start >= len(s):
#         break


for i in range(len(s)):
    start = 0
    end = i + 1
    
    while(True):
    
        # print(f'{start} {end}')
        
        num = int(s[start:end])
        if num % 2019 == 0:
            count += 1
        
        if end + 1 > len(s):
            break;
            
        start += 1
        end += 1

print(count)

Submission status: Wrong Answer

Solution code:
s = input()
"""ans=0"""
l = len(s)
x = [str(2019*i) for i in range(1,101)]
"""for i in range(l+1):
    for j in range(i+1,l+1):
        sij= s[i:j]
        sij=int(sij)
        if sij%2019==0:
            ans+=1"""
an=0
for i in range(1,l+1):
    print(s[i:])
    for xi in x:
        an+=(xi in s[i:])
print(an//4)

Submission status: Wrong Answer

Solution code:
str = input()
ans = 0
for x in range(len(str) - 4):
    if x + 4 < len(str) and int(str[x : x + 5]) % 2019 == 0: ans += 1
    if x + 5 < len(str) and int(str[x : x + 6]) % 2019 == 0: ans += 1
print(ans)