Buggy python submission (verdict: Runtime Error):
n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b

for i in range(n):
    for d in range(n):
        j=i+d
        k=j+d
        if k>=n:
            break
        if s[i]!=s[j] & s[j]!=s[k] & s[k]!=s[i]:
            ans-=1

print(ans)

Fixed submission:
n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b

for i in range(n):
    for d in range(n):
        j=i+d
        k=j+d
        if k>=n:
            break
        if (s[i]!=s[j]) & (s[j]!=s[k]) & (s[k]!=s[i]):
            ans-=1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
sum=0

for i in range(n):
    for j in range(n):
        for k in range(n):
            if not (i<j<k):
                continue
            if (s[i]!=s[j])&(s[j]!=s[k])&(s[k]!=s[i])&(j-i!=k-j):
                sum+=1

print(sum)


Fixed submission:
n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b

for i in range(n):
    for d in range(n):
        j=i+d
        k=j+d
        if k>=n:
            break
        if (s[i]!=s[j]) & (s[j]!=s[k]) & (s[k]!=s[i]):
            ans-=1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
sum=0

for i in range(n):
    for j in range(n):
        for k in range(n):
            if not (i<j<k):
                continue
            if (s[i]!=s[j])&(s[j]!=s[k])&(s[k]!=s[i])&(j-i!=k-j):
                sum+=1

print(sum)


Fixed submission:
n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b

for i in range(n):
    for d in range(n):
        j=i+d
        k=j+d
        if k>=n:
            break
        if (s[i]!=s[j]) & (s[j]!=s[k]) & (s[k]!=s[i]):
            ans-=1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
char_list = list(s)
sum=0

for i in range(n):
    for j in range(n):
        for k in range(n):
            #print("i,j,k:{},{},{}".format(i,j,k))
            if not (i<j<k):
                continue
            if ([char_list[i],char_list[j],char_list[k]]==["R", "G", "B"])&(j-i!=k-j):
                sum+=1
                #print("i,j,k:{},{},{}".format(i,j,k))
            elif ([char_list[i],char_list[j],char_list[k]]==["R", "B", "G"])&(j-i!=k-j):
                sum+=1
                #print("i,j,k:{},{},{}".format(i,j,k))
            elif ([char_list[i],char_list[j],char_list[k]]==["G", "R", "B"])&(j-i!=k-j):
                sum+=1
                #print("i,j,k:{},{},{}".format(i,j,k))
            elif ([char_list[i],char_list[j],char_list[k]]==["G", "B", "R"])&(j-i!=k-j):
                sum+=1
                #print("i,j,k:{},{},{}".format(i,j,k))
            elif ([char_list[i],char_list[j],char_list[k]]==["B", "G", "R"])&(j-i!=k-j):
                sum+=1
                #print("i,j,k:{},{},{}".format(i,j,k))
            elif ([char_list[i],char_list[j],char_list[k]]==["B", "R", "G"])&(j-i!=k-j):
                sum+=1
                #print("i,j,k:{},{},{}".format(i,j,k))

print(sum)


Fixed submission:
n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b

for i in range(n):
    for d in range(n):
        j=i+d
        k=j+d
        if k>=n:
            break
        if (s[i]!=s[j]) & (s[j]!=s[k]) & (s[k]!=s[i]):
            ans-=1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
char_list = list(s)
sum=0

for i in range(n):
    for j in range(n):
        for k in range(n):
            #print("i,j,k:{},{},{}".format(i,j,k))
            if not (i<j<k):
                continue
            if ([char_list[i],char_list[j],char_list[k]]==["R", "G", "B"])&(j-i!=k-j):
                sum+=1
                #print("i,j,k:{},{},{}".format(i,j,k))
            elif ([char_list[i],char_list[j],char_list[k]]==["R", "B", "G"])&(j-i!=k-j):
                sum+=1
                #print("i,j,k:{},{},{}".format(i,j,k))
            elif ([char_list[i],char_list[j],char_list[k]]==["G", "R", "B"])&(j-i!=k-j):
                sum+=1
                #print("i,j,k:{},{},{}".format(i,j,k))
            elif ([char_list[i],char_list[j],char_list[k]]==["G", "B", "R"])&(j-i!=k-j):
                sum+=1
                #print("i,j,k:{},{},{}".format(i,j,k))
            elif ([char_list[i],char_list[j],char_list[k]]==["B", "G", "R"])&(j-i!=k-j):
                sum+=1
                #print("i,j,k:{},{},{}".format(i,j,k))
            elif ([char_list[i],char_list[j],char_list[k]]==["B", "R", "G"])&(j-i!=k-j):
                sum+=1
                #print("i,j,k:{},{},{}".format(i,j,k))

print(sum)


Fixed submission:
n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b

for i in range(n):
    for d in range(n):
        j=i+d
        k=j+d
        if k>=n:
            break
        if (s[i]!=s[j]) & (s[j]!=s[k]) & (s[k]!=s[i]):
            ans-=1

print(ans)