Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
count = 0
for i in range(1,n-1):
    for j in range((i+1),n):
        if not s[i-1] == s[j-1]:
            for k in range((j+1),n+1):
                if not j-i == k-j:
                    if not s[i-1] == s[k-1] and not s[j-1] == s[k-1]:
                        count +=1
print(count)

Fixed submission:
n = int(input())
s = input()
all = s.count("R")*s.count("G")*s.count("B")
for x in range(n-1):
    for y in range(1,(n-1-x)//2+1):
        if s[x] != s[x+y] and s[x]!= s[x+2*y]\
        and s[x+y]!=s[x+2*y]:
            all -=1
print(all)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
count = 0
for i in range(1,n-1):
    for j in range((i+1),n):
        if i<j:
            if not s[i-1] == s[j-1]:
                for k in range((j+1),n+1):
                    if j<k:
                        if not j-i == k-j:
                            if not s[i-1] == s[k-1] and not s[j-1] == s[k-1]:
                                count +=1
print(count)

Fixed submission:
n = int(input())
s = input()
all = s.count("R")*s.count("G")*s.count("B")
for x in range(n-1):
    for y in range(1,(n-1-x)//2+1):
        if s[x] != s[x+y] and s[x]!= s[x+2*y]\
        and s[x+y]!=s[x+2*y]:
            all -=1
print(all)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
count = 0
for i in range(1,n-1):
    for j in range((i+1),n):
        if i<j:
            for k in range((j+1),n+1):
                if j<k:
                    if not j-i == k-j:
                        if not s[i-1] == s[j-1] and not \
                        s[i-1] == s[k-1] and not s[j-1] == s[k-1]:
                            count +=1
print(count)

Fixed submission:
n = int(input())
s = input()
all = s.count("R")*s.count("G")*s.count("B")
for x in range(n-1):
    for y in range(1,(n-1-x)//2+1):
        if s[x] != s[x+y] and s[x]!= s[x+2*y]\
        and s[x+y]!=s[x+2*y]:
            all -=1
print(all)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
count = 0
for i in range(1,n-1):
    for j in range((i+1),n):
        for k in range((j+1),n+1):
            if not j-i == k-j:
                if i<j<k:
                    if not s[i-1] == s[j-1] and not \
                    s[i-1] == s[k-1] and not s[j-1] == s[k-1]:
                        count +=1
print(count)

Fixed submission:
n = int(input())
s = input()
all = s.count("R")*s.count("G")*s.count("B")
for x in range(n-1):
    for y in range(1,(n-1-x)//2+1):
        if s[x] != s[x+y] and s[x]!= s[x+2*y]\
        and s[x+y]!=s[x+2*y]:
            all -=1
print(all)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
count = 0
for i in range(1,n-1):
    for j in range((i+1),n):
        for k in range((j+1),n+1):
            if not j-i == k-j:
                if i<j<k:
                    if not s[i-1] == s[j-1]:
                        if not s[i-1] == s[k-1]:
                            if not s[j-1] == s[k-1]:
                                count +=1
print(count)

Fixed submission:
n = int(input())
s = input()
all = s.count("R")*s.count("G")*s.count("B")
for x in range(n-1):
    for y in range(1,(n-1-x)//2+1):
        if s[x] != s[x+y] and s[x]!= s[x+2*y]\
        and s[x+y]!=s[x+2*y]:
            all -=1
print(all)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = input()
count = 0
for i in range(1,n-1):
    for j in range(1,n):
        for k in range(1,n+1):
            if not j-i == k-j:
                if i<j<k:
                    if not s[i-1] == s[j-1]:
                        if not s[i-1] == s[k-1]:
                            if not s[j-1] == s[k-1]:
                                count +=1
print(count)

Fixed submission:
n = int(input())
s = input()
all = s.count("R")*s.count("G")*s.count("B")
for x in range(n-1):
    for y in range(1,(n-1-x)//2+1):
        if s[x] != s[x+y] and s[x]!= s[x+2*y]\
        and s[x+y]!=s[x+2*y]:
            all -=1
print(all)