output_description: Print the number of pairs of integers (i,j) (1 ≤ i ≤ j ≤ |S|) that satisfy the
  condition.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S
attempt: import sys
  
  stdin = sys.stdin
  
  ns = lambda: stdin.readline().rstrip()
  ni = lambda: int(stdin.readline().rstrip())
  nm = lambda: map(int, stdin.readline().split())
  nl = lambda: list(map(int, stdin.readline().split()))
  
  j = [[[] for k in range(10)] for i in range(3)]
  for i in range(50):
      jjj = 2019 * i
      if "0" not in str(jjj):
          j[0][jjj % 10].append(str(jjj))
  for i in range(50, 552):
      jjj = 2019 * i
      if "0" not in str(jjj):
          j[1][jjj % 10].append(str(jjj))
  for i in range(552, 1000):
      jjj = 2019 * i
      if "0" not in str(jjj):
          j[2][jjj % 10].append(str(jjj))
  s = ns()
  co = 0
  if len(s) > 4:
      jc = [s[0:5], s[1:6], s[0:6]]
      jp = int(s[4])
      if jc[0] in j[0][jp]:
          co += 1
      jp = int(s[5])
  if len(s) > 5:
      if jc[1] in j[0][jp]:
          co += 1
      if jc[2] in j[1][jp]:
          co += 1
  if len(s) > 6:
      for i in range(len(s) - 6):
          jp = int(s[i + 6])
          jc = [s[i + 2 : i + 7], s[i + 1 : i + 7], s[i : i + 7]]
          for k in range(3):
              if jc[k] in j[k][jp]:
                  co += 1
  print(co)
  
problem_description: 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.
samples: [{"input": "1817181712114", "output": "3\n    \n\nThree pairs - (1,5), (5,9), and (9,13) \\- satisfy the condition.\n\n* * *"}, {"input": "14282668646", "output": "2\n    \n\n* * *"}, {"input": "2119", "output": "0\n    \n\nNo pairs satisfy the condition."}]