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('')
max_s = int(20000)
rec = 0
for m in range(max_s+1):
    ms=str(2019*m)
    if not '0' in ms:
        idx=s.find(ms)
        while idx >= 0:
            rec+=1
            idx=s.find(ms,idx+1)
#            print("{} {}".format(ms,idx))
print(rec)

Submission status: Wrong Answer

Solution code:
s = input()

m = []

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


cnt = 0


for i in m:
	for k in range(len(s)-1):
		if s[k:k+1] == i[0:1]:
			if  i == s[k:k+len(i)]:
				# print(i,s[k:k+len(i)])
				cnt += 1

print(cnt)

Submission status: Wrong Answer

Solution code:
S = input()
N = len(S)
Cnt = 0
for i in range(N-3):
	S_tmp = S[i:]
	for j in range(i+4, N+1):
		if int(S_tmp[:j])%2019 == 0:
			Cnt += 1

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 % 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()
li = []
i = 2019
while int(i) < 400000:
    i += 2019
    c = str(i)
    if c in s:
        a = [x for x in range(len(s)) if s.startswith(c, x)] 
        for b in a:
            li.append(b)
print(len(li))

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):
    if s[i:i+len(c)]==c:
      ans += 1

      
  

print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

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

Submission status: Wrong Answer

Solution code:
s = input()
count = 0

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

print(count)

Submission status: Wrong Answer

Solution code:
from collections import deque
import copy

l = deque(list(input()))
now = deque([])
ans = 0

for _ in range(min(3, now.__len__())):
  now.append(l.popleft())
  
while l:
  now.append(l.popleft())
  nxt = deque([])
  while now:
    if int("".join(now)) % 2019 == 0:
      ans += 1
      while now.__len__() > 1:
        now.popleft()
      nxt = copy.deepcopy(now)
    nxt.append(now.popleft())
  now = copy.deepcopy(nxt)

print(ans)

Submission status: Wrong Answer

Solution code:
s = str(input())
mlist = []
for i in range(1, 100):
  m = i * 2019
  mlist.append(str(m))
mcount = 0
flist = []
for j in mlist:
  count = s.count(j)
  if count > 0:
    flist.append(j)
for k in flist:
  fcount = 0
  for l in range(len(s) - len(k) + 1):
    fs = s.count(k, l, l + len(k))
    if fs > 0:
      fcount += fs
  if fcount > 0:
    mcount += fcount 
print(mcount)

Submission status: Wrong Answer

Solution code:
import sys
s = str(input())

cnt = [0 for i in range(len(s))]

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

for i in range(len(s)-3):
    for j in range(i + 3, min(len(s), i+6)):
        if int(s[i:j+1]) % 2019 == 0:
            cnt[j] += cnt[i-1] + 1
else:
    print(sum(cnt))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

S = input()
lis_2019 = [2019 * i for i in range(1, 99)]
cnt = 0
S_len = len(S)
cnt_1 = 0
S_lis = [S]

for i in range(4, S_len):
    while cnt_1 != S_len - i + 1:
        for j in lis_2019:
            if j == S[cnt_1:cnt_1+i]:
                cnt += 1
        cnt_1 += 1
    cnt_1 = 0

print(cnt)

Submission status: Wrong Answer

Solution code:
s = input()
if len(s) <= 3:
  print(0)
  exit()

chk = [str((i+1)*2019) for i in range(1000)]
ans = 0
for i in chk:
    if s.count(i[1:]) > 0:
      ans += s.count(i[1:])
      k = i[0]
      for j in range(1,10):
        if j == int(k):
          continue
        ans -= s.count(str(j)+i[1:])
    
print(ans)

Submission status: Wrong Answer

Solution code:
#d
N = str(input())
a = []
 
def func(string,p):
    count=0
    for x in range(len(string)-len(p)+1):
        if string[x:x+len(p)]==p:
            count+=1
    return count
 
for i in range(1,1000):
    a.append(str(2019*i))

if len(N)<4:
    print(0)
else:
    ans=0
    for j in a:
        ans+=func(N,j)
    print(ans)

Submission status: Wrong Answer

Solution code:
s=str(input())
l=[]
t=0
for i in range(1,len(s)):
    g=int(s[0:i+1])
    g=g%2019
    l.append(g)
    
for i in range(0,2019):
    z=l.count(i)
    if z>1:
        t+=(z*(z-1))%2
print(t)

Submission status: Wrong Answer

Solution code:
S=input()
N=['0']*1000
count=0
j=12114
for i in range(0,1000):
    while True:
        if str(j).count('0')==0:
            N[i]=str(j)
            j+=2019
            break
        else:
            j+=2019
for i in range(0,1000):
    count+=S.count(N[i])
    if S.count(N[i])>0:
        if N[i][0]==N[i][-1]:
            count+=S.count(N[i][1:])-S.count(N[i])
print(count)

Submission status: Wrong Answer

Solution code:
S=str(input())
list=[]

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

l=len(list)
res=0
j=0

while(j<l):
  if(list[j] in S):
    N=S
    while(list[j] in N):
      res+=1
      a=N.find(list[j])
      N=N[a+1:]
  j+=1
print(res)

Submission status: Wrong Answer

Solution code:
S = input()

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

Submission status: Wrong Answer

Solution code:
def main():
    s = input()
    s_l = len(s)
    l = []
    l_a = l.append
    for x in range(s_l):
        if not int(s[x:x+5]) % 2019:
            l_a(0)
    print(len(l))

main()

Submission status: Wrong Answer

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

ans = 0


i = 0
while i < l - 4:
  print(s[i:i + 5])
  if int(s[i:i + 5]) % 2019 == 0:
    ans += 1
  i += 1

print(ans)

Submission status: Wrong Answer

Solution code:
l = []
for i in range(1, 10000):
    l.append(str(2019*i))

s = input()
ans = dict()
for i in l:
    if i in s:
        for j in range(len(s)-len(i)+1):
            if s[j:j+len(i)] == i:
                ans[str(j+1)+"-"+str(j+len(i))] = 1

# print(l)
print(len(ans))
# print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline
from functools import reduce

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    S = input()
    S = str(S)
    #Slist = [int(x) for x in list(str(S))]
    #N = len(Slist)
    ans = 0
    a = [str(2019*xx) for xx in range(1,100)]

    #print(a)
    #print(N)

    for i in a:
        if i in S:
            ans += 1
            S2 = S[S.find(i)+1:]
            #print("S2",S2)
            while True:
                if i in S2:
                    ans += 1
                    S2 = S2[S2.find(i)+1:]
                    #print("S3",S2)
                else:
                    break
            #if S.count(i)>=2:
                #ans = ans + S.count(i) -1
    print(ans)



"""
    for i in range(N-3):
        for j in range(i+3,N):
            num_list = [0]*(j-i+1)
            num_list = [Slist[k] for k in range(i,j+1)]
            num = int(reduce(lambda x, y: x + y, [str(x) for x in num_list]))
            if num % 2019 == 0:
                ans += 1
            #print(num)
    
    print(ans)
"""


if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import sympy as syp(素因数分解とか)
Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    s = input()
    n = len(s)
    ans = 0
    if n <= 3:
        print(0)
    else:
        for i in range(3,min(n+1,9)):
            for j in range(n - i + 1):
                if int(s[j: j + i]) % 2019 == 0:
                    ans += 1
    print(ans)
if __name__ == "__main__":
    main() #endline===============================================

Submission status: Wrong Answer

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

while 1:
    if len(s)-1<c+4:
        break
    a+=1
    c+=4
print(a)

Submission status: Wrong Answer

Solution code:
from sys import stdin
input = stdin.readline
def main():
  S=input()
  S_len=len(S)
  s_count=0
  for i in range(0,S_len-3):
    for j in range(i+3,S_len):
      tgtS=S[i:j+1]
      int_tgtS=int(tgtS)
      if(int_tgtS%2019==0):
        s_count=s_count+1
  print(s_count)
if __name__ == '__main__':
    main()

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 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:
s = input()
keta = len(s)
ans = 0
mul = []

for i in range(100):
    if "0" in str(2019 * i):
        pass
    else:
        mul.append(str(2019 * i))

for i in range(len(mul) - 1):
    for j in range(0, keta + 1 - len(str(mul[i]))):
        if s[j : j + len(mul[i])] == mul[i]:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
S = input()
s = len(S)
ss = 5
cnt = 0
if s<5:
  print(0)
else:
  while ss != s:
    for i in range(s-ss+1):
      if int(S[i:i+ss])%2019==0:
        print(S[i:i+ss])
        cnt += 1
        i += ss-1
    ss += 1
  print(cnt)

Submission status: Wrong Answer

Solution code:
s = input()

n = len(s)
res = 0
# for i in range(n-3):
#     for j in range(i+3,n):
#         num = int(s[i:j+1])
#
#         # print(num)
#         if num % 2019 == 0:
#             res += 1
#         # if i == 0 and j == 4:
#         #     print(num % 2019)
#
# print(res)

memo = ["019",
"038",
"057",
"076",
"095",
"114",
"133",
"152",
"171",
"190",
"209",
"228",
"247",
"266",
"285",
"304",
"323",
"342",
"361",
"380",
"399",
"418",
"437",
"456",
"475",
"494",
"513",
"532",
"551",
"570",
"589",
"608",
"627",
"646",
"665",
"684",
"703",
"722",
"741",
"760",
"779",
"798",
"817",
"836",
"855",
"874",
"893",
"912",
"931",
"950",
"969",
"988",
"007",
"026",
"045",
"064",
"083",
"102",
"121",
"140",
"159",
"178",
"197",
"216",
"235",
"254",
"273",
"292",
"311",
"330",
"349",
"368",
"387",
"406",
"425",
"444",
"463",
"482",
"501",
"520",
"539",
"558",
"577",
"596",
"615",
"634",
"653",
"672",
"691",
"710",
"729",
"748",
"767",
"786",
"805",
"824",
"843",
"862",
"881",
"900",
"919",
"938",
"957",
"976",
"995",
"014",
"033",
"052",
"071",
"090",
"109",
"128",
"147",
"166",
"185",
"204",
"223",
"242",
"261",
"280",
"299",
"318",
"337",
"356",
"375",
"394",
"413",
"432",
"451",
"470",
"489",
"508",
"527",
"546",
"565",
"584",
"603",
"622",
"641",
"660",
"679",
"698",
"717",
"736",
"755",
"774",
"793",
"812",
"831",
"850",
"869",
"888",
"907",
"926",
"945",
"964",
"983",
"002",
"021",
"040",
"059",
"078",
"097",
"116",
"135",
"154",
"173",
"192",
"211",
"230",
"249",
"268",
"287",
"306",
"325",
"344",
"363",
"382",
"401",
"420",
"439",
"458",
"477",
"496",
"515",
"534",
"553",
"572",
"591",
"610",
"629",
"648",
"667",
"686",
"705",
"724",
"743",
"762",
"781",
"800",
"819",
"838",
"857",
"876",
"895",
"914",
"933",
"952",
"971",
"990",
"009",
"028",
"047",
"066",
"085",
"104",
"123",
"142",
"161",
"180",
"199",
"218",
"237",
"256",
"275",
"294",
"313",
"332",
"351",
"370",
"389",
"408",
"427",
"446",
"465",
"484",
"503",
"522",
"541",
"560",
"579",
"598",
"617",
"636",
"655",
"674",
"693",
"712",
"731",
"750",
"769",
"788",
"807",
"826",
"845",
"864",
"883",
"902",
"921",
"940",
"959",
"978",
"997",
"016",
"035",
"054",
"073",
"092",
"111",
"130",
"149",
"168",
"187",
"206",
"225",
"244",
"263",
"282",
"301",
"320",
"339",
"358",
"377",
"396",
"415",
"434",
"453",
"472",
"491",
"510",
"529",
"548",
"567",
"586",
"605",
"624",
"643",
"662",
"681",
"700",
"719",
"738",
"757",
"776",
"795",
"814",
"833",
"852",
"871",
"890",
"909",
"928",
"947",
"966",
"985",
"004",
"023",
"042",
"061",
"080",
"099",
"118",
"137",
"156",
"175",
"194",
"213",
"232",
"251",
"270",
"289",
"308",
"327",
"346",
"365",
"384",
"403",
"422",
"441",
"460",
"479",
"498",
"517",
"536",
"555",
"574",
"593",
"612",
"631",
"650",
"669",
"688",
"707",
"726",
"745",
"764",
"783",
"802",
"821",
"840",
"859",
"878",
"897",
"916",
"935",
"954",
"973",
"992",
"011",
"030",
"049",
"068",
"087",
"106",
"125",
"144",
"163",
"182",
"201",
"220",
"239",
"258",
"277",
"296",
"315",
"334",
"353",
"372",
"391",
"410",
"429",
"448",
"467",
"486",
"505",
"524",
"543",
"562",
"581",
"600",
"619",
"638",
"657",
"676",
"695",
"714",
"733",
"752",
"771",
"790",
"809",
"828",
"847",
"866",
"885",
"904",
"923",
"942",
"961",
"980",
"999",
"018",
"037",
"056",
"075",
"094",
"113",
"132",
"151",
"170",
"189",
"208",
"227",
"246",
"265",
"284",
"303",
"322",
"341",
"360",
"379",
"398",
"417",
"436",
"455",
"474",
"493",
"512",
"531",
"550",
"569",
"588",
"607",
"626",
"645",
"664",
"683",
"702",
"721",
"740",
"759",
"778",
"797",
"816",
"835",
"854",
"873",
"892",
"911",
"930",
"949",
"968",
"987",
"006",
"025",
"044",
"063",
"082",
"101",
"120",
"139",
"158",
"177",
"196",
"215",
"234",
"253",
"272",
"291",
"310",
"329",
"348",
"367",
"386",
"405",
"424",
"443",
"462",
"481",
"500",
"519",
"538",
"557",
"576",
"595",
"614",
"633",
"652",
"671",
"690",
"709",
"728",
"747",
"766",
"785",
"804",
"823",
"842",
"861",
"880",
"899",
"918",
"937",
"956",
"975",
"994",
"013",
"032",
"051",
"070",
"089",
"108",
"127",
"146",
"165",
"184",
"203",
"222",
"241",
"260",
"279",
"298",
"317",
"336",
"355",
"374",
"393",
"412",
"431",
"450",
"469",
"488",
"507",
"526",
"545",
"564",
"583",
"602",
"621",
"640",
"659",
"678",
"697",
"716",
"735",
"754",
"773",
"792",
"811",
"830",
"849",
"868",
"887",
"906",
"925",
"944",
"963",
"982",
"001",
"020",
"039",
"058",
"077",
"096",
"115",
"134",
"153",
"172",
"191",
"210",
"229",
"248",
"267",
"286",
"305",
"324",
"343",
"362",
"381",
"400",
"419",
"438",
"457",
"476",
"495",
"514",
"533",
"552",
"571",
"590",
"609",
"628",
"647",
"666",
"685",
"704",
"723",
"742",
"761",
"780",
"799",
"818",
"837",
"856",
"875",
"894",
"913",
"932",
"951",
"970",
"989",
"008",
"027",
"046",
"065",
"084",
"103",
"122",
"141",
"160",
"179",
"198",
"217",
"236",
"255",
"274",
"293",
"312",
"331",
"350",
"369",
"388",
"407",
"426",
"445",
"464",
"483",
"502",
"521",
"540",
"559",
"578",
"597",
"616",
"635",
"654",
"673",
"692",
"711",
"730",
"749",
"768",
"787",
"806",
"825",
"844",
"863",
"882",
"901",
"920",
"939",
"958",
"977",
"996",
"015",
"034",
"053",
"072",
"091",
"110",
"129",
"148",
"167",
"186",
"205",
"224",
"243",
"262",
"281",
"300",
"319",
"338",
"357",
"376",
"395",
"414",
"433",
"452",
"471",
"490",
"509",
"528",
"547",
"566",
"585",
"604",
"623",
"642",
"661",
"680",
"699",
"718",
"737",
"756",
"775",
"794",
"813",
"832",
"851",
"870",
"889",
"908",
"927",
"946",
"965",
"984",
"003",
"022",
"041",
"060",
"079",
"098",
"117",
"136",
"155",
"174",
"193",
"212",
"231",
"250",
"269",
"288",
"307",
"326",
"345",
"364",
"383",
"402",
"421",
"440",
"459",
"478",
"497",
"516",
"535",
"554",
"573",
"592",
"611",
"630",
"649",
"668",
"687",
"706",
"725",
"744",
"763",
"782",
"801",
"820",
"839",
"858",
"877",
"896",
"915",
"934",
"953",
"972",
"991",
"010",
"029",
"048",
"067",
"086",
"105",
"124",
"143",
"162",
"181",
"200",
"219",
"238",
"257",
"276",
"295",
"314",
"333",
"352",
"371",
"390",
"409",
"428",
"447",
"466",
"485",
"504",
"523",
"542",
"561",
"580",
"599",
"618",
"637",
"656",
"675",
"694",
"713",
"732",
"751",
"770",
"789",
"808",
"827",
"846",
"865",
"884",
"903",
"922",
"941",
"960",
"979",
"998",
"017",
"036",
"055",
"074",
"093",
"112",
"131",
"150",
"169",
"188",
"207",
"226",
"245",
"264",
"283",
"302",
"321",
"340",
"359",
"378",
"397",
"416",
"435",
"454",
"473",
"492",
"511",
"530",
"549",
"568",
"587",
"606",
"625",
"644",
"663",
"682",
"701",
"720",
"739",
"758",
"777",
"796",
"815",
"834",
"853",
"872",
"891",
"910",
"929",
"948",
"967",
"986",
"005",
"024",
"043",
"062",
"081",
"100",
"119",
"138",
"157",
"176",
"195",
"214",
"233",
"252",
"271",
"290",
"309",
"328",
"347",
"366",
"385",
"404",
"423",
"442",
"461",
"480",
"499",
"518",
"537",
"556",
"575",
"594",
"613",
"632",
"651",
"670",
"689",
"708",
"727",
"746",
"765",
"784",
"803",
"822",
"841",
"860",
"879",
"898",
"917",
"936",
"955",
"974",
"993",
"012",
"031",
"050",
"069",
"088",
"107",
"126",
"145",
"164",
"183",
"202",
"221",
"240",
"259",
"278",
"297",
"316",
"335",
"354",
"373",
"392",
"411",
"430",
"449",
"468",
"487",
"506",
"525",
"544",
"563",
"582",
"601",
"620",
"639",
"658",
"677",
"696",
"715",
"734",
"753",
"772",
"791",
"810",
"829",
"848",
"867",
"886",
"905",
"924",
"943",
"962",
"981",
"000",
"019"]

for i in range(n,2,-1):
    sub_s = s[i-3:i]
    print(sub_s)
    if sub_s in memo:
        # print(i)
        for j in range(i-3,-1,-1):
            num = int(s[j:i])
            # print("aaa")
            # print(i)
            # print(j)
            # print(num)

            if(num % 2019 == 0):
                # print("res//////////////////////////////////////////////")
                res +=1
            # print()
print(res)

Submission status: Wrong Answer

Solution code:
S=input()
N = len(S)
arr = []
ans = [0 for i in range(2020)]
cnt0 = 0
for i in range(N):
  a = int(S[N-i-1:N])%2019
  ans[a] += 1
  arr.append(a)
  if a == 0:
    cnt0 += 1
cnt = 0
for i in range(1,1010):
  cnt += ans[i] * ans[2019-i]
  
cnt = int(cnt + (cnt0+1)*cnt0/2)
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

def LI(): return list(map(int, stdin.readline().split()))
def LS(): return list(stdin.readline())

s = input()
ans = 0
same = []
l = [str(i*2019) for i in range(1, 100)]
for i in l:
    if i in s:
        same.append(i)
for i in same:
    m = s
    while True:
        idx = m.find(i)
        m = m[idx+1:]
        # print(i, m)
        if idx==-1:
            break
        ans += 1
# print(l)

print(ans)

Submission status: Wrong Answer

Solution code:
S = input()

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

Submission status: Wrong Answer

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

cnt = 0
flag = False
tmp_j = 0
for i in range(len_S-4):
    if flag:
        flag = False
        i = tmp_j
    for j in range(i+3, len_S):
        tmp = int(S[i:j+1])
        if tmp % 2019 == 0:
            cnt += 1
            tmp_j = j
            flag = True
            break



print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import Counter

S = input()
#S = "1"*20000

p = 2019
N = len(S)

m = [(int(S[i]) * pow(10, N-i, p)) % p for i in range(N)]

# m の mod 累積和
r = [0] * N
r[0] = m[0]
for ri in range(1, N):
    r[ri] = (r[ri-1] + m[ri]) % p

# この r[i] が一致するような区間が答えになるのでこれをもとめる
c = Counter(r)

ans = 0
for ci in [cv for cv in c.values() if cv >= 2]:
    ans += ci * (ci-1) // 2

if 0 in c.keys():
    ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
A = ["19","38","57","76","95","14","33","52","71"]
S = input()
N = len(S)
cnt = 0

while N > 4:
    if S[N-2:] in A:
        for i in range(N-2):
            if int(S[i:]) % 2019 == 0:
                cnt += 1
        S = S[:N-1]
        N -= 1
    else:
        S = S[:N-1]
        N -= 1
print(cnt)

Submission status: Wrong Answer

Solution code:
s = input()
count = 0

for i in range(len(s)):
    for j in range(i+1,len(s)+1):
        a = s[i:(j*4)]
        if int(a) % 2019 == 0:
            count += 1
            
print(count)

Submission status: Wrong Answer

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

ans = 0

i = 0
while i < l - 5:
  if int(s[i:i + 5]) % 2019 == 0:
    ans += 1
  i += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def strToInt(s:list):
    l = len(s)
    tmp = ""
    for i in range(l):
        tmp += s[i]
    return int(tmp)

s = list(input())
l = len(s)
i = 0
j = 1
cnt=0
for i in range(l-1):
    for j in range(i+1,l):
        if int(strToInt(s[i:j]))%2019 == 0:
            cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
S = input()

count = 0
skip = -1
for i in range(len(S)):
    if i < skip - 1:
        continue
    for j in range(i + 1, len(S) + 1):
        if len(S[i:j]) < 4:
            continue
        # print(S[i:j], i, j)
        if int(S[i:j]) % 2019 == 0:
            count += 1
            # print("(%s, %s)" % (i, j))
            skip = j
            break


print(count)

Submission status: Wrong Answer

Solution code:
s = input()

a = []
for i in range(1,101):
  a.append(str(i * 2019))
ans = 0
for i in a:
    if i[0] == i[-1]:
        count = s.count(i[:-1])
    else:
        count = s.count(i)
    ans += count
      
print(ans)

Submission status: Wrong Answer

Solution code:
def check(s,i,c):
    if i >= len(s):
        return c
    if int(s[i:i+4]) % 2019 == 0:
        c += 1
        return check(s,i+4,c)
    elif len(str(int(s[i:i+5]))) == 5 and int(s[i:i+5]) % 2019 == 0 and int(s[i:i+5])!= int(s[i:i+4]):
        c += 1
        return check(s,i+5,c)
    else:
        return c

s = input()
cnt = 0
li = []
for i in range(0,len(s)-3):
    a = int(s[i:i+4])
    b = int(s[i:i+5])
    if a % 2019 == 0:
        cnt += 1
        cnt += check(s,i+4,0)
    if b % 2019 == 0 and len(str(b)) ==5:
        cnt += 1
        cnt += check(s,i+5,0)
print(cnt)

Submission status: Wrong Answer

Solution code:
S = input()
digitnum = len(S)
ans = 0

for begindigit in range(0, digitnum - 4):
    for enddigit in range(begindigit + 4, digitnum + 1):
        judgeS = int(S[begindigit:enddigit])
        if judgeS < 2019:
            break
        elif judgeS % 2019 == 0:
            ans = ans + 1

print(ans)

Submission status: Wrong Answer

Solution code:
s=input()
n=len(s)
ans=0
i=0
here=0
flag=0
#print(s[5:10])
while i<n-3:
    j=i+5
    while j<n+1:
       # print(i,j)
        if (int(s[i:j])%2019==0):
            #print("koko",i,j)
            ans+=1
            here=j
            j+=4
            flag=1
        if (flag==1 and j-here==9):
            break
        j+=1
    i+=1
print(ans)

Submission status: Wrong Answer

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

for i in range(1,100):
    a = str(2019*i)
    len_a = len(a)
    
    tmp = s.count(a)
    if tmp > 0:
        for j in range(len_s - len_a + 1):
            cnt += s.count(a, j, j+len_a)
    #tmp = s.count(a)
    #cnt += tmp
    #if tmp > 0:
     #   print(tmp, a)
print(cnt)

Submission status: Wrong Answer

Solution code:
nn = input()
c = 0
i = 1
nnn = 0

while len(str(nnn)) < 6:
    nnn = str(2019 * i)
    if int(nnn) >= int(nn):
        break
    i+=1

    if nnn in nn:
        c+=sum([nn[k:k+len(nnn)]==nnn for k in range(0, len(nn)-len(nnn)+1)])
print(c)

Submission status: Wrong Answer

Solution code:
S = input()

ls = [0for i in range(len(S))]

for i in range(len(S)):
    # 4~7桁で見たときの2019の倍数の区間
    if int(S[i]) == 0:
        continue
    for j in range(4,8):
        if i+j <= len(S):
            x = int(S[i:i+j])
            if x % 2019 == 0:
                # 今調べている区間につながる倍数の数＋自身
                ls[i+j-1] += 1
                if i > 0:
                    ls[i+j-1] += ls[i-1]
                if S[i+j-1] == '0' and i+j < len(S):
                    ls[i+j] += ls[i+j-1]

count = 0
for i in ls:
    count += i

print(count)

Submission status: Wrong Answer

Solution code:
s=input()
count=0
if len(s)<=3:
  print(0)
  exit()
if len(s)==4:
  if int(s)%2019==0:
    print(1)
    exit()
  else:
    print(0)
    exit()
for i in range(0,len(s)-3):
  for j in range(i+4,len(s)+1):
    s_tmp=s[i:j]
    if int(s_tmp)>=200001:
      break
    if int(s_tmp)%2019==0:
      count+=1
print(count)

Submission status: Wrong Answer

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

cnt = 0
flag = False
tmp_j = 0
for i in range(len_S-4):
    if flag:
        flag = False
        i = tmp_j
    for j in range(i+3, len_S):
        tmp = int(S[i:j+1])
        print(tmp)
        if tmp % 2019 == 0:
            cnt += 1
            tmp_j = j
            flag = True
            break



print(cnt)

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 index==1 and temp_num==0:
            tot+=1
        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:
import sys
input = sys.stdin.readline

s = input().rstrip()
n = len(s)
ranges = []
g = [[] for _ in range(n + 1)]
ans = 0

for i in range(n):
    for j in range(i + 3, i + 10):
        if j >= n:
            continue
        s_ = s[i:j + 1]
        if int(s_) % 2019 == 0:
            ranges.append([i, j + 1])
            g[i].append(j + 1)

visited = set()
ans = 0

for i in range(n):
    if i in visited or len(g[i]) == 0:
        continue
    visited.add(i)
    d = 1
    while True:
        i = g[i][0]
        if len(g[i]) == 0:
            ans += (1 + d) * d // 2
            break
        else:
            d += 1
            visited.add(i)

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
S = input()
print(len(S))
dict_amari = {}
count = 0

henkan = {i: [(10*j+i)%2019 for j in range(2019)] for i in range(1,10)}

def amari_new(dict_amari, s, henkan):
  dict_amari_new = {henkan[k] : v for k,v in dict_amari.items()}
  if s in dict_amari_new.keys():
    dict_amari_new[s] += 1
  else:
    dict_amari_new[s] = 1
  return dict_amari_new

for s in S:
  dict_amari = amari_new(dict_amari, int(s), henkan[int(s)])
  if 0 in dict_amari.keys():
    count += dict_amari[0]

print(count)

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 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:
s=input()
# print(len(s));
i=0
count=0

for k in range(4,10):
    i=0
    for j in range(k,len(s)+1):

    
        m=s[i:j]
        i=i+1
        # print(m)
    
        # print(int(m))
        if int(m)%2019==0:
            count+=1
        # i=i+1

print(count)

Submission status: Wrong Answer

Solution code:
s = str(input())
num = 0
i = 0
#num1= 0
while True:
  for k in range(i, len(s)):
#    print(i,k+4, int(s[i:k+4]), len(s))
#    num1 += 1
    if k+4 > len(s):
      break
    if int(s[i:k+4]) % 2019 == 0:
      num += 1
      print("OK")
  i += 1
  if i == len(s)-1:
    break
print(num)
#print(num1)

Submission status: Wrong Answer

Solution code:
import re
S = input()
B_list = []
for i in range(1,100):
    B_list.append(str(i*2019))

result = 0
for v in B_list:
    for t in range(len(S) - len(v) + 1):
        S_new = S[t : len(v)+t]
        if v == S_new:
            result += 1

print(result)