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

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


ans = r * g * b

for i in range(n):
    for j in range(i + 1, n):
        if 2 * j - i > n - 1:
            continue
        if s[i] == s[j] or s[i] == s[2 * j - i] or s[j] == s[2 * j - i]:
            pass
        else:
            ans -= 1
print(ans)

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

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


ans = r * g * b

for i in range(n):
    for j in range(i + 1, n):
        if 2 * j - i > n - 1:
            continue
        if s[i] == s[j] or s[i] == s[2 * j - i] or s[j] == s[2 * j - i]:
            pass
        else:
            ans -= 1
print(ans)

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

r = []
g = []
b = []

for i, c in enumerate(s):
    if c == "R":
        r.append(i)
    elif c == "G":
        g.append(i)
    else:
        b.append(i)


ans = 0
for ri in r:
    for gi in g:
        for bi in b:
            arr = [ri, gi, bi]
            arr.sort()
            if arr[0] + arr[2] == 2 * arr[1]:
                pass
            else:
                ans += 1

print(ans)

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

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


ans = r * g * b

for i in range(n):
    for j in range(i + 1, n):
        if 2 * j - i > n - 1:
            continue
        if s[i] == s[j] or s[i] == s[2 * j - i] or s[j] == s[2 * j - i]:
            pass
        else:
            ans -= 1
print(ans)

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

r = []
g = []
b = []

for i, c in enumerate(s):
    if c == "R":
        r.append(i)
    elif c == "G":
        g.append(i)
    else:
        b.append(i)


ans = 0
for ri in r:
    for gi in g:
        for bi in b:
            arr = [ri, gi, bi]
            arr.sort()
            if arr[0] + arr[2] == 2 * arr[1]:
                pass
            else:
                ans += 1

print(ans)

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

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


ans = r * g * b

for i in range(n):
    for j in range(i + 1, n):
        if 2 * j - i > n - 1:
            continue
        if s[i] == s[j] or s[i] == s[2 * j - i] or s[j] == s[2 * j - i]:
            pass
        else:
            ans -= 1
print(ans)

Buggy python submission (verdict: Runtime Error):
cd ../n = int(input())
s = input()

r = []
g = []
b = []

for i, c in enumerate(s):
    if c == "R":
        r.append(i)
    elif c == "G":
        g.append(i)
    else:
        b.append(i)


ans = 0
for ri in r:
    for gi in g:
        for bi in b:
            arr = [ri, gi, bi]
            arr.sort()
            if arr[0] + arr[2] == 2 * arr[1]:
                pass
            else:
                ans += 1

print(ans)

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

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


ans = r * g * b

for i in range(n):
    for j in range(i + 1, n):
        if 2 * j - i > n - 1:
            continue
        if s[i] == s[j] or s[i] == s[2 * j - i] or s[j] == s[2 * j - i]:
            pass
        else:
            ans -= 1
print(ans)

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

r = []
g = []
b = []

for i, c in enumerate(s):
    if c == "R":
        r.append(i)
    elif c == "G":
        g.append(i)
    else:
        b.append(i)


ans = 0
for ri in r:
    for gi in g:
        for bi in b:
            if abs(ri - gi) == abs(gi - bi) or abs(ri - bi) == abs(gi - bi) or abs(ri - bi) == abs(ri - gi):
                pass
            else:
                ans += 1

print(ans)

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

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


ans = r * g * b

for i in range(n):
    for j in range(i + 1, n):
        if 2 * j - i > n - 1:
            continue
        if s[i] == s[j] or s[i] == s[2 * j - i] or s[j] == s[2 * j - i]:
            pass
        else:
            ans -= 1
print(ans)