output_description: Print the value of \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K}
  \gcd(a,b,c)}.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      K
attempt: from itertools import product
  
  x1 = int(input())
  x2 = input()
  
  R_i = [i for i, x in enumerate(x2) if x == "R"]
  G_i = [i for i, x in enumerate(x2) if x == "G"]
  B_i = {i for i, x in enumerate(x2) if x == "B"}
  
  R = len(R_i)
  G = len(G_i)
  B = len(B_i)
  
  xs = map(sorted, product(R_i, G_i))
  
  s = 0
  for a in xs:
      k = a[1] * 2 - a[0]  # 2j-i
      if k in B_i:
          s += 1
      i = a[0] * 2 - a[1]  # 2j-k
      if i in B_i:
          s += 1
      j = (a[0] + a[1]) / 2
      if j.is_integer():
          j = int(j)
          if j in B_i:
              s += 1
  print(R * G * B - s)
  
problem_description: Statement
  
  Find \displaystyle{\sum_{a=1}^{K}\sum_{b=1}^{K}\sum_{c=1}^{K} \gcd(a,b,c)}.
  
  Here \gcd(a,b,c) denotes the greatest common divisor of a, b, and c.
samples: [{"input": "2", "output": "9\n    \n\n\\gcd(1,1,1)+\\gcd(1,1,2)+\\gcd(1,2,1)+\\gcd(1,2,2)\n+\\gcd(2,1,1)+\\gcd(2,1,2)+\\gcd(2,2,1)+\\gcd(2,2,2) =1+1+1+1+1+1+1+2=9\n\nThus, the answer is 9.\n\n* * *"}, {"input": "200", "output": "10813692"}]