Buggy python submission (verdict: Runtime Error):
@njit
def solve():
    n, s = int(input()), input()
    a = ["R", "G", "B"]
    cnt = [0, 0, 0]
        for i in s:
        cnt[a.index(i)] += 1
    c = cnt[0] * cnt[1] * cnt[2]
    for i in range(1, n-1):
        for j in range(i+1, n):
            k = 2 * j - i
            if j-1 < k-1 < n:
                if s[i-1] != s[j-1] and s[j-1] != s[k-1] and s[k-1] != s[i-1]:
                    c -= 1
    return c
print(solve())

Fixed submission:
n, s = int(input()), input()
a = ["R", "G", "B"]
cnt = [0, 0, 0]
for i in s:
    cnt[a.index(i)] += 1
c = cnt[0] * cnt[1] * cnt[2]
for i in range(1, n-1):
    for j in range(i+1, n):
        k = 2 * j - i
        if j-1 < k-1 < n:
            if s[i-1] != s[j-1] and s[j-1] != s[k-1] and s[k-1] != s[i-1]:
                c -= 1

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n, s = int(input()), input()
a = ["R", "G", "B"]
cnt = [0, 0, 0]
for i in s:
    cnt[a.index(i)] += 1
c = cnt[0] * cnt[1] * cnt[2]
for i in range(1, n+1):
    for j in range(i+1, n+1):
        k = 2 * j - i
        if j < k <= n:
            if s[i-1] != s[j-1] and s[j-1] != s[k-1] and s[k-1] != s[i-1]:
                c -= 1

print(c)

Fixed submission:
n, s = int(input()), input()
a = ["R", "G", "B"]
cnt = [0, 0, 0]
for i in s:
    cnt[a.index(i)] += 1
c = cnt[0] * cnt[1] * cnt[2]
for i in range(1, n-1):
    for j in range(i+1, n):
        k = 2 * j - i
        if j-1 < k-1 < n:
            if s[i-1] != s[j-1] and s[j-1] != s[k-1] and s[k-1] != s[i-1]:
                c -= 1

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n, s = int(input()), input()
sm = 0
for i in range(n - 2):
    for j in range(i, n - 1):
        for k in range(j, n):
            if k != 2 * j - i and s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
                sm += 1
print(sm)


Fixed submission:
n, s = int(input()), input()
a = ["R", "G", "B"]
cnt = [0, 0, 0]
for i in s:
    cnt[a.index(i)] += 1
c = cnt[0] * cnt[1] * cnt[2]
for i in range(1, n-1):
    for j in range(i+1, n):
        k = 2 * j - i
        if j-1 < k-1 < n:
            if s[i-1] != s[j-1] and s[j-1] != s[k-1] and s[k-1] != s[i-1]:
                c -= 1

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
n, s = int(input()), input()
sm = 0
for i in range(n - 2):
    for j in range(i, n - 1):
        for k in range(j, n):
            if k != 2 * j - i and s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
                sm += 1
print(sm)

Fixed submission:
n, s = int(input()), input()
a = ["R", "G", "B"]
cnt = [0, 0, 0]
for i in s:
    cnt[a.index(i)] += 1
c = cnt[0] * cnt[1] * cnt[2]
for i in range(1, n-1):
    for j in range(i+1, n):
        k = 2 * j - i
        if j-1 < k-1 < n:
            if s[i-1] != s[j-1] and s[j-1] != s[k-1] and s[k-1] != s[i-1]:
                c -= 1

print(c)

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

cnt = 0
for i in range(1, n-2):
    for i in range(i+1, n-1):
        for k in range(j+1,n)
        if k != j * 2 - i:
            if s[i-1] != s[j-1] and s[i-1] != s[k-1] and s[j-1] != s[k-1]:
                cnt += 1

print(cnt)

Fixed submission:
n, s = int(input()), input()
a = ["R", "G", "B"]
cnt = [0, 0, 0]
for i in s:
    cnt[a.index(i)] += 1
c = cnt[0] * cnt[1] * cnt[2]
for i in range(1, n-1):
    for j in range(i+1, n):
        k = 2 * j - i
        if j-1 < k-1 < n:
            if s[i-1] != s[j-1] and s[j-1] != s[k-1] and s[k-1] != s[i-1]:
                c -= 1

print(c)