Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter

N = int(input())
S = input()

counter = Counter(S)

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if 0 <= k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cnt += 1

print(counter["R"]*counter["G"]*counter["B"] - cnt)

Fixed submission:
N = int(input())
S = input()

r = S.count("R")
g = S.count("G")
b = S.count("B")

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if 0 <= k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cnt += 1

print(r*g*b - cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
S = np.array(list(input()))

r = (S == "R").sum()
g = (S == "G").sum()
b = (S == "B").sum()

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if 0 <= k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cnt += 1

print(r*g*b - cnt)

Fixed submission:
N = int(input())
S = input()

r = S.count("R")
g = S.count("G")
b = S.count("B")

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if 0 <= k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cnt += 1

print(r*g*b - cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())

import numpy as np

S = np.array(S)

r = (S == "R").sum()
g = (S == "G").sum()
b = (S == "B").sum()

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if 0 <= k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cnt += 1

print(r*g*b - cnt)

Fixed submission:
N = int(input())
S = input()

r = S.count("R")
g = S.count("G")
b = S.count("B")

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if 0 <= k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cnt += 1

print(r*g*b - cnt)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())

import numpy as np

r = (np.array(S) == "R").sum()
g = (np.array(S) == "G").sum()
b = (np.array(S) == "B").sum()

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if 0 <= k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cnt += 1

print(r*g*b - cnt)

Fixed submission:
N = int(input())
S = input()

r = S.count("R")
g = S.count("G")
b = S.count("B")

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if 0 <= k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cnt += 1

print(r*g*b - cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())

import numpy as np

r = (np.array(S) == "R").sum()
g = (np.array(S) == "G").sum()
b = (np.array(S) == "B").sum()

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if 0 <= k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cnt += 1

print(r*g*b - cnt)

Fixed submission:
N = int(input())
S = input()

r = S.count("R")
g = S.count("G")
b = S.count("B")

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if 0 <= k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cnt += 1

print(r*g*b - cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

ans = 0
for j in range(N):
    original = list("RGB")
    if S[j] in original:
        for i in range(j):
            obj = [a for a in original if a != S[j]]
            if S[i] in obj:
                for k in range(j+1, N):
                    if (j-i) != (k-j):
                        obj_2 = [b for b in obj if b != S[i]]
                        if S[k] == obj_2[0]:
                        	ans += 1
print(ans)


Fixed submission:
N = int(input())
S = input()

r = S.count("R")
g = S.count("G")
b = S.count("B")

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if 0 <= k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cnt += 1

print(r*g*b - cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

ans = 0
for j in range(N):
    original = "RGB"
    if S[j] in original:
        for i in range(j):
            obj = original.replace(S[j], "")
            if S[i] in obj:
                for k in range(j+1, N):
                    if (j-i) != (k-j):
                        obj_2 = obj.replace(S[i], "")
                        if S[k] == obj_2:
                        	ans += 1
print(ans)



Fixed submission:
N = int(input())
S = input()

r = S.count("R")
g = S.count("G")
b = S.count("B")

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if 0 <= k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cnt += 1

print(r*g*b - cnt)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = input()

ans = 0
for j in range(N):
    original = "RGB"
    if S[j] in original:
        for i in range(j):
            obj = original.replace(S[j], "")
            if S[i] in obj:
                for k in range(j+1, N):
                    obj_2 = obj.replace(S[i], "")
                    if S[k] == obj_2:
                      	if (j-i) != (k-j):
                        	ans += 1
print(ans)


Fixed submission:
N = int(input())
S = input()

r = S.count("R")
g = S.count("G")
b = S.count("B")

cnt = 0
for i in range(N):
    for j in range(i+1, N):
        k = j + j - i
        if 0 <= k < N:
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                cnt += 1

print(r*g*b - cnt)