Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())

ans = 0

for x in range(n):
  for y in range(n):
    if not x < y:
      continue
    if s[x] == s[y]:
      continue
    for z in range(n):
      if not y < z:
        continue

      if not x < y < z:
        # print("SKIP: ", x, y, z)
        continue

      if y-x == z-y:
        # print("SKIP: ", x, y, z)
        continue

      if not ((s[x] != s[y]) and (s[x] != s[z]) and (s[y] != s[z])):
        # print("SKIP: ", x, y, z)
        continue

      ans += 1
      # print(x, y, z)
      # print(s[x], s[y], s[z])

print(ans)


Fixed submission:
n = int(input())
s = list(input())

ans = s.count("R") * s.count("G") * s.count("B")

for i in range(n):
  for j in range(n):
    if not i < j:
      continue
    k = j + (j-i)
    if k < n and "".join(sorted([s[i], s[j], s[k]])) == "BGR":
      ans -= 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())

ans = 0

for x in range(n):
  for y in range(n):
    if not x < y:
      continue
    if s[x] == s[y]:
      continue
    for z in range(n):
      if not x < y < z:
        # print("SKIP: ", x, y, z)
        continue

      if y-x == z-y:
        # print("SKIP: ", x, y, z)
        continue

      if not ((s[x] != s[y])  and (s[x] != s[z]) and (s[y] != s[z])):
        # print("SKIP: ", x, y, z)
        continue

      ans += 1
      # print(x, y, z)
      # print(s[x], s[y], s[z])

print(ans)


Fixed submission:
n = int(input())
s = list(input())

ans = s.count("R") * s.count("G") * s.count("B")

for i in range(n):
  for j in range(n):
    if not i < j:
      continue
    k = j + (j-i)
    if k < n and "".join(sorted([s[i], s[j], s[k]])) == "BGR":
      ans -= 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())

ans = 0

for x in range(n):
  for y in range(n):
    if not x < y:
      continue
    if s[x] == s[y]:
      continue
    for z in range(n):
      if not x < y < z:
        # print("SKIP: ", x, y, z)
        continue

      if "".join( sorted([s[x], s[y], s[z]]) ) != "BGR":
        # print("SKIP: ", x, y, z)
        continue

      if y-x == z-y:
        # print("SKIP: ", x, y, z)
        continue

      ans += 1
      # print(x, y, z)
      # print(s[x], s[y], s[z])

print(ans)


Fixed submission:
n = int(input())
s = list(input())

ans = s.count("R") * s.count("G") * s.count("B")

for i in range(n):
  for j in range(n):
    if not i < j:
      continue
    k = j + (j-i)
    if k < n and "".join(sorted([s[i], s[j], s[k]])) == "BGR":
      ans -= 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())

ans = 0

for x in range(n):
  for y in range(n):
    if not x < y:
      continue
    for z in range(n):
      if not x < y < z:
        # print("SKIP: ", x, y, z)
        continue

      if "".join( sorted([s[x], s[y], s[z]]) ) != "BGR":
        # print("SKIP: ", x, y, z)
        continue

      if y-x == z-y:
        # print("SKIP: ", x, y, z)
        continue

      ans += 1
      # print(x, y, z)
      # print(s[x], s[y], s[z])

print(ans)


Fixed submission:
n = int(input())
s = list(input())

ans = s.count("R") * s.count("G") * s.count("B")

for i in range(n):
  for j in range(n):
    if not i < j:
      continue
    k = j + (j-i)
    if k < n and "".join(sorted([s[i], s[j], s[k]])) == "BGR":
      ans -= 1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = list(input())

ans = 0

for x in range(n):
  for y in range(n):
    for z in range(n):
      if not x < y < z:
        # print("SKIP: ", x, y, z)
        continue

      if "".join( sorted([s[x], s[y], s[z]]) ) != "BGR":
        # print("SKIP: ", x, y, z)
        continue

      if y-x == z-y:
        # print("SKIP: ", x, y, z)
        continue

      ans += 1
      # print(x, y, z)
      # print(s[x], s[y], s[z])

print(ans)


Fixed submission:
n = int(input())
s = list(input())

ans = s.count("R") * s.count("G") * s.count("B")

for i in range(n):
  for j in range(n):
    if not i < j:
      continue
    k = j + (j-i)
    if k < n and "".join(sorted([s[i], s[j], s[k]])) == "BGR":
      ans -= 1

print(ans)