Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(input())
a = 0
b = 0
c = 0
count = 0
for i in range(N - 2):
  for j in range(i + 1, N - 1):
    if arr[i] != arr[j]:
      for k in range(j + 1, N):
        if j - i != k - j:
          a = k
          b = j 
          c = i
          if arr[a] != arr[b] and arr[c] != arr[b] and arr[a] != arr[c]:
            count += 1
print(count)

Fixed submission:
N = int(input())
arr = list(input())
a = arr.count("R")
b = arr.count("G")
c = arr.count("B")
count = a * b * c

for i in range(N - 2):
  for j in range(i + 1, N - 1):
    k = i + (j - i) * 2
    if k < N and arr[i] != arr[j] and arr[j] != arr[k] and arr[k] != arr[i]:
      count -= 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(input())
a = 0
b = 0
c = 0
count = 0
for i in range(N - 2):
  for j in range(i + 1, N - 1):
    if arr[i] != arr[j]:
      for k in range(j + 1, N):
        if j - i != k - j:
          a = k
          b = j 
          c = i
          if arr[a] == arr[b] or arr[c] == arr[b] or arr[a] == arr[c]:
            continue
          else:
            count += 1
print(count)

Fixed submission:
N = int(input())
arr = list(input())
a = arr.count("R")
b = arr.count("G")
c = arr.count("B")
count = a * b * c

for i in range(N - 2):
  for j in range(i + 1, N - 1):
    k = i + (j - i) * 2
    if k < N and arr[i] != arr[j] and arr[j] != arr[k] and arr[k] != arr[i]:
      count -= 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(input())
a = 0
b = 0
c = 0
count = 0
for i in range(N - 2):
  for j in range(i + 1, N - 1):
    for k in range(j + 1, N):
      if k - j != j - i:
        a = k
        b = j 
        c = i
        if arr[a] == arr[b] or arr[c] == arr[b] or arr[a] == arr[c]:
          continue
        else:
          count += 1
print(count)

Fixed submission:
N = int(input())
arr = list(input())
a = arr.count("R")
b = arr.count("G")
c = arr.count("B")
count = a * b * c

for i in range(N - 2):
  for j in range(i + 1, N - 1):
    k = i + (j - i) * 2
    if k < N and arr[i] != arr[j] and arr[j] != arr[k] and arr[k] != arr[i]:
      count -= 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(input())
a = 0
b = 0
c = 0
count = 0
for i in range(N - 2):
  for j in range(i + 1, N - 1):
    for k in range(j + 1, N):
      if k - j != j - i:
        a = k
        b = j 
        c = i
        count += 1
        
        if arr[a] == arr[b] or arr[c] == arr[b] or arr[a] == arr[c]:
          count -= 1
print(count)

Fixed submission:
N = int(input())
arr = list(input())
a = arr.count("R")
b = arr.count("G")
c = arr.count("B")
count = a * b * c

for i in range(N - 2):
  for j in range(i + 1, N - 1):
    k = i + (j - i) * 2
    if k < N and arr[i] != arr[j] and arr[j] != arr[k] and arr[k] != arr[i]:
      count -= 1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
arr = list(input())
R = []
G = []
B = []
result = 0
for i in range(len(arr)):
  if arr[i] == "R":
    R.append(i)
  elif arr[i] == "G":
    G.append(i)
  elif arr[i] == "B":
    B.append(i)

for i in R:
  for j in G:
    for k in B:
      if abs(j - i) == abs(k - j) or abs(j - i) == abs(i - k) or abs(k - i) == abs(k - j):
        result += 1
print(len(R) * len(G) * len(B) - result)

Fixed submission:
N = int(input())
arr = list(input())
a = arr.count("R")
b = arr.count("G")
c = arr.count("B")
count = a * b * c

for i in range(N - 2):
  for j in range(i + 1, N - 1):
    k = i + (j - i) * 2
    if k < N and arr[i] != arr[j] and arr[j] != arr[k] and arr[k] != arr[i]:
      count -= 1
print(count)