Buggy python submission (verdict: Runtime Error):
n = int(input())
s = input()
#ans = s.count('R')*s.count('G')*s.count('B')
ans = 0
for i in range(n-2):
	s1 = s[i]
	for j in range(i+1,n-1):
    	s2 = s[j]
        if s1 == s2:
        	pass
        else:
        	s[2*j-i] != s1 and s[2*j-i] != s2:
            ans += 1
print(ans)

Fixed submission:
N = int(input())
S= input()
sub = 0
R,G,B = [],[],[]
r = S.count('R')
g = S.count('G')
b = S.count('B') 
for i in range(N):
    for j in range(i+1,N):
        if 2*j-i > N-1:
            break
        if S[i] != S[j] and S[2*j-i] != S[i] and S[2*j-i] != S[j]:
            sub += 1
ans = r*g*b -sub
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S= input()
sub = 0
R,G,B = [],[],[]
r = S.count('R')
g = S.count('G')
b = S.count('B') 
for i in range(N):
    for j in range(i+1,N+1):
        if S[i] != S[j] and S[2*j-i] != S[i] and S[2*j-i] != S[j]:
            sub += 1
ans = r*g*b -sub
print(ans)
       

Fixed submission:
N = int(input())
S= input()
sub = 0
R,G,B = [],[],[]
r = S.count('R')
g = S.count('G')
b = S.count('B') 
for i in range(N):
    for j in range(i+1,N):
        if 2*j-i > N-1:
            break
        if S[i] != S[j] and S[2*j-i] != S[i] and S[2*j-i] != S[j]:
            sub += 1
ans = r*g*b -sub
print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S= input()
count = 0
R,G,B = [],[],[]
r = S.count('R')
g = S.count('G')
b = S.count('B') 
for i in range(N):
    for j in range(i+1,N+1):
        if S[i] != S[j] and S[2*j-i] != S[i] and S[2*j-i] != S[j]:
            sub += 1
ans = r*g*b -sub
print(ans)
       

Fixed submission:
N = int(input())
S= input()
sub = 0
R,G,B = [],[],[]
r = S.count('R')
g = S.count('G')
b = S.count('B') 
for i in range(N):
    for j in range(i+1,N):
        if 2*j-i > N-1:
            break
        if S[i] != S[j] and S[2*j-i] != S[i] and S[2*j-i] != S[j]:
            sub += 1
ans = r*g*b -sub
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S= input()
count = 0
R,G,B = [],[],[]
for i in S:
    if i == 'R':
        R.append(count)
    elif i == 'G':
        G.append(count)
    else:
        B.append(count)
    count += 1
sub = 0
for r in R:
    for g in G:
        for b in B:
            if b==2*r-g or b==2*g-r or b==(r+g)/2:
                sub +=1
ans = len(R)*len(G)*len(B) -sub
print(ans)
       

Fixed submission:
N = int(input())
S= input()
sub = 0
R,G,B = [],[],[]
r = S.count('R')
g = S.count('G')
b = S.count('B') 
for i in range(N):
    for j in range(i+1,N):
        if 2*j-i > N-1:
            break
        if S[i] != S[j] and S[2*j-i] != S[i] and S[2*j-i] != S[j]:
            sub += 1
ans = r*g*b -sub
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S= input()
ret = 0
count = 0
R,G,B = [],[],[]
for i in S:
    if i == 'R':
        R.append(count)
    elif i == 'G':
        G.append(count)
    else:
        B.append(count)
    count += 1

for r in R:
    for g in G:
        i = min(r,g)
        j = max(r,g)
        for b in B:
            if i < b < j and b != (i+j)/2:
                ret +=1
            if j < b and b != 2*j -i:
                ret +=1
            if b < i and b != 2*i-j:
                ret += 1
print(ret)

Fixed submission:
N = int(input())
S= input()
sub = 0
R,G,B = [],[],[]
r = S.count('R')
g = S.count('G')
b = S.count('B') 
for i in range(N):
    for j in range(i+1,N):
        if 2*j-i > N-1:
            break
        if S[i] != S[j] and S[2*j-i] != S[i] and S[2*j-i] != S[j]:
            sub += 1
ans = r*g*b -sub
print(ans)