output_description: Print the sum of all numbers among the first N terms of the FizzBuzz sequence.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
attempt: from collections import defaultdict
  
  
  def solve(rr, gg, bb):
      d1, d2 = defaultdict(list), defaultdict(list)
      for i in range(len(gg)):
          ii = gg[i]
          for j in range(len(rr)):
              jj = rr[j]
              if ii > jj:
                  d1[ii].append(ii - jj)
      for i in range(len(gg)):
          ii = gg[i]
          for j in range(len(bb)):
              jj = bb[j]
              if ii < jj:
                  d2[ii].append(jj - ii)
      s = 0
      # print(d1,d2)
      for x in d1:
          for y in d1[x]:
              for z in d2[x]:
                  if y != z:
                      s += 1
      return s
  
  
  n = int(input())
  s = input()
  l = list(s)
  rr, gg, bb = [], [], []
  for i in range(len(s)):
      ii = s[i]
      if ii == "R":
          rr.append(i)
      if ii == "G":
          gg.append(i)
      if ii == "B":
          bb.append(i)
  # print(rr,gg,bb)
  print(
      solve(rr, gg, bb)
      + solve(rr, bb, gg)
      + solve(bb, rr, gg)
      + solve(bb, gg, rr)
      + solve(gg, rr, bb)
      + solve(gg, bb, rr)
  )
  
problem_description: Statement
  
  Let us define the **FizzBuzz sequence** a_1,a_2,... as follows:
  
    * If both 3 and 5 divides i, a_i=\mbox{FizzBuzz}.
    * If the above does not hold but 3 divides i, a_i=\mbox{Fizz}.
    * If none of the above holds but 5 divides i, a_i=\mbox{Buzz}.
    * If none of the above holds, a_i=i.
  
  Find the sum of all numbers among the first N terms of the FizzBuzz sequence.
samples: [{"input": "15", "output": "60\n    \n\nThe first 15 terms of the FizzBuzz sequence are:\n\n1,2,\\mbox{Fizz},4,\\mbox{Buzz},\\mbox{Fizz},7,8,\\mbox{Fizz},\\mbox{Buzz},11,\\mbox{Fizz},13,14,\\mbox{FizzBuzz}\n\nAmong them, numbers are 1,2,4,7,8,11,13,14, and the sum of them is 60.\n\n* * *"}, {"input": "1000000", "output": "266666333332\n    \n\nWatch out for overflow."}]