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

def SUMCHK():
    N = int(input())
    S = input()

    C=Counter(S)
    r = C['R']
    g = C['G']
    b = C['B']


    cnt = r * g * b

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

    cnt -= sum

    print(cnt)

SUMCHK()

Fixed submission:
import itertools
from collections import Counter

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

C=Counter(S)
r = C['R']
g = C['G']
b = C['B']


cnt = r * g * b

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

print(cnt)

Buggy python submission (verdict: Runtime Error):
import itertools
from collections import Counter

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

C=Counter(S)
r = C['R']
g = C['G']
b = C['B']


cnt = r * g * b

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

print(cnt)

Fixed submission:
import itertools
from collections import Counter

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

C=Counter(S)
r = C['R']
g = C['G']
b = C['B']


cnt = r * g * b

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

print(cnt)

Buggy python submission (verdict: Runtime Error):
import itertools
from collections import Counter

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

C=Counter(S)
r = C['R']
g = C['G']
b = C['B']


cnt = r * g * b

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

print(cnt)


Fixed submission:
import itertools
from collections import Counter

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

C=Counter(S)
r = C['R']
g = C['G']
b = C['B']


cnt = r * g * b

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

print(cnt)

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

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

C=Counter(S)
r = C['R']
g = C['G']
b = C['B']


cnt = r * g * b

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

cnt -= sum

print(cnt)

Fixed submission:
import itertools
from collections import Counter

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

C=Counter(S)
r = C['R']
g = C['G']
b = C['B']


cnt = r * g * b

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

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

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

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


cnt = r * g * b

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

print(cnt)

Fixed submission:
import itertools
from collections import Counter

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

C=Counter(S)
r = C['R']
g = C['G']
b = C['B']


cnt = r * g * b

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

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

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

sum = 0
for i in range(0,N-2):
    for j in range(i+1,N-1):
        if S[i] == S[j]:
            continue
        for k in range(j+1,N):
            if S[i] == S[k] or S[j] == S[k]:
                continue
            if j - i != k - j:
                if (S[i] != S[j]) and (S[i] != S[k] and S[j] != S[k]):
                    sum += 1

print(sum)


Fixed submission:
import itertools
from collections import Counter

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

C=Counter(S)
r = C['R']
g = C['G']
b = C['B']


cnt = r * g * b

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

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

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

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

print(sum)


Fixed submission:
import itertools
from collections import Counter

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

C=Counter(S)
r = C['R']
g = C['G']
b = C['B']


cnt = r * g * b

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

print(cnt)