output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      S
attempt: def sum(a, n):
  
      # map to keep a count of occurrences
  
      cnt = dict()
  
      # Traverse in the list from start to end
  
      # number of times a[i] can be in a pair and
  
      # to get the difference we subtract pre_sum.
  
      ans = 0
  
      pre_sum = 0
  
      for i in range(n):
  
          ans += (i * a[i]) - pre_sum
  
          pre_sum += a[i]
  
          # if the (a[i]-1) is present then
  
          # subtract that value as f(a[i], a[i]-1)=0
  
          if (a[i] - 1) in cnt:
  
              ans -= cnt[a[i] - 1]
  
          # if the (a[i]+1) is present then add that
  
          # value as f(a[i], a[i]-1)=0 here we add
  
          # as a[i]-(a[i]-1)<0 which would have been
  
          # added as negative sum, so we add to remove
  
          # this pair from the sum value
  
          if (a[i] + 1) in cnt:
  
              ans += cnt[a[i] + 1]
  
          # keeping a counter for every element
  
          if a[i] not in cnt:
  
              cnt[a[i]] = 0
  
          cnt[a[i]] += 1
  
      return ans
  
  
  # Driver Code
  
  if __name__ == "__main__":
  
      a = [1, 2, 3, 1, 3]
  
      n = len(a)
  
      print(sum(a, n))
  
problem_description: Statement
  
  For a positive integer n, let us define f(n) as the number of digits in base
  10.
  
  You are given an integer S. Count the number of the pairs of positive integers
  (l, r) (l \leq r) such that f(l) + f(l + 1) + ... + f(r) = S, and find the
  count modulo 10^9 + 7.
samples: [{"input": "1", "output": "9\n    \n\nThere are nine pairs (l, r) that satisfies the condition: (1, 1), (2, 2), ...,\n(9, 9).\n\n* * *"}, {"input": "2", "output": "98\n    \n\nThere are 98 pairs (l, r) that satisfies the condition, such as (1, 2) and\n(33, 33).\n\n* * *"}, {"input": "123", "output": "460191684\n    \n\n* * *"}, {"input": "36018", "output": "966522825\n    \n\n* * *"}, {"input": "1000", "output": "184984484"}]