Buggy python submission (verdict: Runtime Error):
length = int(input())
text = input()

r_count = text.count("R")
g_count = text.count("G")
b_count = text.count("B")

answer = r_count * g_count * b_count

for i in range(length-2):
    for j in range(i+1, length-1):
        k = i + (i-j)*2
        if k < length and text[i]!=text[j] and text[i]!=text[k] and text[j]!=text[k]:
            answer -= 1
        
print(answer)

Fixed submission:
length = int(input())
text = input()

r_count = text.count("R")
g_count = text.count("G")
b_count = text.count("B")

answer = r_count * g_count * b_count

for i in range(length-2):
    for j in range(i+1, length-1):
        k = i + (j-i)*2
        if k < length and text[i]!=text[j] and text[i]!=text[k] and text[j]!=text[k]:
            answer -= 1
        
print(answer)

Buggy python submission (verdict: Runtime Error):
length = int(input())
text = input()

r_count = text.count("R")
g_count = text.count("G")
b_count = text.count("B")

answer = r_count * g_count * b_count

for i in range(length-2):
    for j in range(i+1, length-1):
        k = i + (i-j)*2
        if k < length and text[i]!=text[j] and text[i]!=text[k] and text[j]!=text[k]:
            answer -= 1
        
print(answer)

Fixed submission:
length = int(input())
text = input()

r_count = text.count("R")
g_count = text.count("G")
b_count = text.count("B")

answer = r_count * g_count * b_count

for i in range(length-2):
    for j in range(i+1, length-1):
        k = i + (j-i)*2
        if k < length and text[i]!=text[j] and text[i]!=text[k] and text[j]!=text[k]:
            answer -= 1
        
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
from statistics import median
length = int(input())
text = list(input())

r_list = []
g_list = []
b_list = []

count = 0
for i, c in enumerate(text):
    if c == "R":
        r_list.append(i)
    elif c == "G":
        g_list.append(i)
    else:
        b_list.append(i)

num_list = [0, 0, 0]
for i in r_list:
    num_list[0] = i
    for j in g_list:
        num_list[1] = j
        for k in b_list:
            num_list[2] = k
            d1 = max(num_list) - median(num_list)
            d2 = median(num_list) - min(num_list)
            if d1 != d2:
                count += 1
print(count)

Fixed submission:
length = int(input())
text = input()

r_count = text.count("R")
g_count = text.count("G")
b_count = text.count("B")

answer = r_count * g_count * b_count

for i in range(length-2):
    for j in range(i+1, length-1):
        k = i + (j-i)*2
        if k < length and text[i]!=text[j] and text[i]!=text[k] and text[j]!=text[k]:
            answer -= 1
        
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
# 文字数を入力
length = int(input())
# テキストを1文字ずつのリストで入力
text = list(input())
# 組み合わせの数のカウント変数
count = 0
# 総当たりで組み合わせを調べる
for i, c1 in zip(range(1, length+1), text[0:]):
    for j, c2 in zip(range(i+1, length+1), text[i:]):
        for k, c3 in zip(range(j+1, length+1), text[j:]):
            if (j - i != k - j) and (c1 != c2 and c1 != c3 and c2 != c3):
                count += 1
print(count)

Fixed submission:
length = int(input())
text = input()

r_count = text.count("R")
g_count = text.count("G")
b_count = text.count("B")

answer = r_count * g_count * b_count

for i in range(length-2):
    for j in range(i+1, length-1):
        k = i + (j-i)*2
        if k < length and text[i]!=text[j] and text[i]!=text[k] and text[j]!=text[k]:
            answer -= 1
        
print(answer)