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: S = input()
  magniMap5 = {
      "0": 5,
      "1": 5,
      "2": 4,
      "3": 4,
      "4": 3,
      "5": 3,
      "6": 2,
      "7": 2,
      "8": 1,
      "9": 1,
  }
  magniMap6over = {
      "0": 50,
      "1": 45,
      "2": 40,
      "3": 35,
      "4": 30,
      "5": 25,
      "6": 20,
      "7": 15,
      "8": 10,
      "9": 5,
  }
  targets = ["12114"]
  index = 0
  magni = 6
  
  while len(targets[index]) < 10:
      magni += 1
      target = str(2019 * magni)
      zeroIndex = target.find("0")
      while 0 < zeroIndex:
          size = len(target)
          zeroPos = size - zeroIndex
          if zeroPos <= 4:
              magni += 1
          elif zeroPos == 5:
              zeroRightNum = target[-(zeroPos - 1)]
              magni += magniMap5[zeroRightNum]
          else:
              zeroRightNum = target[-(zeroPos - 1)]
              magni += magniMap6over[zeroRightNum] * (10 ** (zeroPos - 6))
          target = str(2019 * magni)
          zeroIndex = target.find("0")
      targets.append(target)
      index += 1
  
  nums = {}
  
  for i in range(len(S) - 5):
      tail = i + 5
  
      while tail <= i + 10:
          part = S[i:tail]
          tail += 1
          if part in nums:
              nums[part] += 1
          else:
              nums[part] = 1
  res = 0
  for target in targets:
      if target in nums:
          res += nums[target]
  
  print(res)
  
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."}]