Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
s_list= list(input())
r_list=[]
g_list=[]
b_list=[]
count=0
rr,gg,bb=0,0,0
for i in range(0,n):
    if s_list[i]=="R":
        r_list.append(i)
        rr=rr+1
    elif s_list[i]=="G":
        g_list.append(i)
        gg=gg+1
    else:
        b_list.append(i)
        bb=bb+1
sum=rr*gg*bb

for pp in r_list:
    for qq in g_list:
        for rr in b_list:
            if rr-pp == -1*(qq-pp) or rr-pp ==2*(qq-pp) or qq-pp ==2*(rr-pp) :
                count=count+1
print(sum-count)

Fixed submission:
n= int(input())
s_list= list(input())
count=0
rr,bb,gg=0,0,0
for i in range(0,n):
    if s_list[i]=="R":
        rr=rr+1
    elif s_list[i]=="G":
        gg=gg+1
    else:
        bb=bb+1
sum=rr*gg*bb

for p in range(0,n-2):
    for q in range(p+1,n-1):
        if s_list[p] == s_list[q]:
            continue
        elif 2*q-p<n and s_list[2*q-p]!=s_list[p] and s_list[2*q-p]!=s_list[q]:
            count= count+1
print(sum-count)

Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
s_list= list(input())
count=0
rr,bb,gg=0,0,0
for i in range(0,n):
    if s_list[i]=="R":
        rr=rr+1
    elif s_list[i]=="G":
        gg=gg+1
    else:
        bb=bb+1
sum=rr*gg*bb

for p in range(0,n-2):
    for q in range(p+1,n-1):
        if s_list[p] == s_list[q]:
            continue
        else:
            for r in range(q+1,n):
                if s_list[r]==s_list[p] or s_list[r]==s_list[q] :
                    continue
                elif r-q==q-p:
                    count = count+1
print(sum-count)

Fixed submission:
n= int(input())
s_list= list(input())
count=0
rr,bb,gg=0,0,0
for i in range(0,n):
    if s_list[i]=="R":
        rr=rr+1
    elif s_list[i]=="G":
        gg=gg+1
    else:
        bb=bb+1
sum=rr*gg*bb

for p in range(0,n-2):
    for q in range(p+1,n-1):
        if s_list[p] == s_list[q]:
            continue
        elif 2*q-p<n and s_list[2*q-p]!=s_list[p] and s_list[2*q-p]!=s_list[q]:
            count= count+1
print(sum-count)

Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
s_list= list(input())
count=0
rr,bb,gg=0,0,0
for i in range(0,n):
    if s_list[i]=="R":
        rr=rr+1
    elif s_list[i]=="G":
        gg=gg+1
    else:
        bb=bb+1
sum=rr*gg*bb

for p in range(0,n-2):
    for q in range(p+1,n-1):
        for r in range(q+1,n):
            if s_list[r]!=s_list[p] and s_list[r]!=s_list[q] and s_list[p]!=s_list[q] and r-q==q-p:
                count = count+1


print(sum-count)

Fixed submission:
n= int(input())
s_list= list(input())
count=0
rr,bb,gg=0,0,0
for i in range(0,n):
    if s_list[i]=="R":
        rr=rr+1
    elif s_list[i]=="G":
        gg=gg+1
    else:
        bb=bb+1
sum=rr*gg*bb

for p in range(0,n-2):
    for q in range(p+1,n-1):
        if s_list[p] == s_list[q]:
            continue
        elif 2*q-p<n and s_list[2*q-p]!=s_list[p] and s_list[2*q-p]!=s_list[q]:
            count= count+1
print(sum-count)

Buggy python submission (verdict: Time Limit Exceeded):
n= int(input())
s_list= list(input())
r_list=[]
g_list=[]
b_list=[]
count=0
for i in range(0,n):
    if s_list[i]=="R":
        r_list.append(i)
    elif s_list[i]=="G":
        g_list.append(i)
    else:
        b_list.append(i)

for pp in r_list:
    for qq in g_list:
        for rr in b_list:
            if rr-pp != -1*(qq-pp) and rr-pp !=2*(qq-pp) and qq-pp !=2*(rr-pp) :
                count=count+1
print(count)

Fixed submission:
n= int(input())
s_list= list(input())
count=0
rr,bb,gg=0,0,0
for i in range(0,n):
    if s_list[i]=="R":
        rr=rr+1
    elif s_list[i]=="G":
        gg=gg+1
    else:
        bb=bb+1
sum=rr*gg*bb

for p in range(0,n-2):
    for q in range(p+1,n-1):
        if s_list[p] == s_list[q]:
            continue
        elif 2*q-p<n and s_list[2*q-p]!=s_list[p] and s_list[2*q-p]!=s_list[q]:
            count= count+1
print(sum-count)