Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
s=input()

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

for i in range(0,n):
    if s[i]=='R':
        r.append(i)

    elif s[i]=='G':
        g.append(i)

    elif s[i]=='B':
        b.append(i)

s3=0
rl=len(r)
gl=len(g)
bl=len(b)

for i in range(0,n-2):
    for j in range(i,n-1):
        k=2*j-i
        if k<=n-1:
            
            if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
                s3+=1
s2=rl*gl*bl-s3
print(s2)

Fixed submission:
import numpy as np
n=int(input())
s=input()

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

for i in range(0,n):
    if s[i]=='R':
        r.append(i)

    elif s[i]=='G':
        g.append(i)

    elif s[i]=='B':
        b.append(i)

s3=0
rl=len(r)
gl=len(g)
bl=len(b)

for i in range(0,n-2):
    n2=int((n+i)/2)+1
    for j in range(i,n2):
        k=2*j-i
        if k<=n-1:
            
            if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
                s3+=1
s2=rl*gl*bl-s3
print(s2)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
s=input()

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

for i in range(0,n):
    if s[i]=='R':
        r.append(i)

    elif s[i]=='G':
        g.append(i)

    elif s[i]=='B':
        b.append(i)

s=0
rl=len(r)
gl=len(g)
bl=len(b)
#ml=max(rl,gl,bl)
#if  ml==rl:
#    d1=r
#    d2=g
#    d3=b
#elif ml==gl:
#    d1=g
#    d2=r
#    d3=b
#else:
#    d1=b
#    d2=g
#    d3=r

for i1 in r:
    for i2 in g:
        if (min(i1,i2)-np.abs(i1-i2)) in b:
            s+=1
        if (max(i1,i2)+np.abs(i1-i2)) in b:
            s+=1
        if (i1+i2)/2.0 in b:
            s+=1

s2=rl*gl*bl-s
print(s2)

Fixed submission:
import numpy as np
n=int(input())
s=input()

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

for i in range(0,n):
    if s[i]=='R':
        r.append(i)

    elif s[i]=='G':
        g.append(i)

    elif s[i]=='B':
        b.append(i)

s3=0
rl=len(r)
gl=len(g)
bl=len(b)

for i in range(0,n-2):
    n2=int((n+i)/2)+1
    for j in range(i,n2):
        k=2*j-i
        if k<=n-1:
            
            if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
                s3+=1
s2=rl*gl*bl-s3
print(s2)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
s=input()

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

for i in range(0,n):
    if s[i]=='R':
        r.append(i)

    elif s[i]=='G':
        g.append(i)

    elif s[i]=='B':
        b.append(i)

s=0
rl=len(r)
gl=len(g)
bl=len(b)
ml=max(rl,gl,bl)
if  ml==rl:
    d1=r
    d2=g
    d3=b
elif ml==gl:
    d1=g
    d2=r
    d3=b
else:
    d1=b
    d2=g
    d3=r

for i1 in d2:
    for i2 in d3:
        if (min(i1,i2)-np.abs(i1-i2)) in d1:
            s+=1
        if (max(i1,i2)+np.abs(i1-i2)) in d1:
            s+=1
        if (i1+i2)/2.0 in d1:
            s+=1

s2=rl*gl*bl-s
print(s2)

Fixed submission:
import numpy as np
n=int(input())
s=input()

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

for i in range(0,n):
    if s[i]=='R':
        r.append(i)

    elif s[i]=='G':
        g.append(i)

    elif s[i]=='B':
        b.append(i)

s3=0
rl=len(r)
gl=len(g)
bl=len(b)

for i in range(0,n-2):
    n2=int((n+i)/2)+1
    for j in range(i,n2):
        k=2*j-i
        if k<=n-1:
            
            if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
                s3+=1
s2=rl*gl*bl-s3
print(s2)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
s=input()

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

for i in range(0,n):
    if s[i]=='R':
        r.append(i)

    elif s[i]=='G':
        g.append(i)

    elif s[i]=='B':
        b.append(i)

s=0
for i1 in r:
    for i2 in g:
        for i3 in b:
            if np.abs(i1-i2)!=np.abs(i1-i3) and np.abs(i1-i2)!=np.abs(i2-i3) and np.abs(i1-i3)!=np.abs(i2-i3):
                s+=1

print(s)

Fixed submission:
import numpy as np
n=int(input())
s=input()

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

for i in range(0,n):
    if s[i]=='R':
        r.append(i)

    elif s[i]=='G':
        g.append(i)

    elif s[i]=='B':
        b.append(i)

s3=0
rl=len(r)
gl=len(g)
bl=len(b)

for i in range(0,n-2):
    n2=int((n+i)/2)+1
    for j in range(i,n2):
        k=2*j-i
        if k<=n-1:
            
            if s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]:
                s3+=1
s2=rl*gl*bl-s3
print(s2)