Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
f=0
ijk = list()
for i in range(N):
    for j in range(N):
        for k in range(N):
            if(k>j>i):
                if(k == j+(j-i)):
                    pass
                elif(i == j-(j-k)):
                    pass
                else:
                    ijk.append([i+1,j+1,k+1])
# print(S)
# print(ijk)

for i in range(len(ijk)):
    if(S[ijk[i][0]-1]== S[ijk[i][1]-1]):pass
    elif(S[ijk[i][0]-1]== S[ijk[i][2]-1]):pass
    elif(S[ijk[i][1]-1]== S[ijk[i][2]-1]):pass
    else:f+=1
print(f)

Fixed submission:
n=int(input())
s=input()
r=g=b=0
for i in s:
  if i=="R":r+=1
  elif i=="G":g+=1
  else:b+=1

ans=r*g*b
for i in range(n):
  for j in range(i+1,n):
    k_ = j+(j-i)
    if(k_ >=n):
      break
    ans -= int(s[i]!= s[j] and s[i] != s[k_] and s[j] != s[k_])

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())
f=0
ijk = list()
for i in range(N):
    for j in range(N):
        for k in range(N):
            if(k>j and j>i):
                if(k == j+(j-i)):
                    pass
                elif(i == j-(j-k)):
                    pass
                else:
                    ijk.append([i+1,j+1,k+1])

for i in range(len(ijk)):
    if(S[ijk[i][0]]!= S[ijk[i][1]] and
       S[ijk[i][0]]!= S[ijk[i][2]] and
       S[ijk[i][1]]!= S[ijk[i][2]]):
       f+=1
print(f)

Fixed submission:
n=int(input())
s=input()
r=g=b=0
for i in s:
  if i=="R":r+=1
  elif i=="G":g+=1
  else:b+=1

ans=r*g*b
for i in range(n):
  for j in range(i+1,n):
    k_ = j+(j-i)
    if(k_ >=n):
      break
    ans -= int(s[i]!= s[j] and s[i] != s[k_] and s[j] != s[k_])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
f=0
i_c = j_c = k_c =1
ijk = list()
for i in range(N):
    for j in range(N):
        for k in range(N):
            if(k_c>j_c and j_c>i_c): 
                if(j_c-i_c==k_c-j_c):
                    pass
                else:
                    ijk.append([i,j,k])
            k_c+=1
        j_c+=1
        k_c = 1
    i_c+=1
    j_c = 1



for i in range(len(ijk)):
    if(S[ijk[i][0]]!= S[ijk[i][1]] and
       S[ijk[i][0]]!= S[ijk[i][2]] and
       S[ijk[i][1]]!= S[ijk[i][2]]):
       f+=1
print(f)

Fixed submission:
n=int(input())
s=input()
r=g=b=0
for i in s:
  if i=="R":r+=1
  elif i=="G":g+=1
  else:b+=1

ans=r*g*b
for i in range(n):
  for j in range(i+1,n):
    k_ = j+(j-i)
    if(k_ >=n):
      break
    ans -= int(s[i]!= s[j] and s[i] != s[k_] and s[j] != s[k_])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
f=0
ijk = list()
for i in range(N):
    for j in range(N):
        for k in range(N):
            if(i<j<k):
                if(S[i]==S[j]):
                    pass
                elif(S[i]==S[k]):
                    pass
                elif(S[j]==S[k]):
                    pass
                else:
                    ijk.append([i+1,j+1,k+1])
# print(ijk)
for i in range(len(ijk)):
    if(ijk[i][1]-ijk[i][0] == ijk[i][2]-ijk[i][1]):
        pass
    else:
        f += 1
print(f)

Fixed submission:
n=int(input())
s=input()
r=g=b=0
for i in s:
  if i=="R":r+=1
  elif i=="G":g+=1
  else:b+=1

ans=r*g*b
for i in range(n):
  for j in range(i+1,n):
    k_ = j+(j-i)
    if(k_ >=n):
      break
    ans -= int(s[i]!= s[j] and s[i] != s[k_] and s[j] != s[k_])

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(input())
f=0
ijk = list()
for i in range(N):
    for j in range(N):
        for k in range(N):
            if(i<j<k):
                if(S[i]==S[j]):
                    pass
                elif(S[i]==S[k]):
                    pass
                elif(S[j]==S[k]):
                    pass
                else:
                    ijk.append([i+1,j+1,k+1])
# print(ijk)
for i in range(len(ijk)):
    if(ijk[i][1]-ijk[i][0] == ijk[i][2]-ijk[i][1]):
        pass:
    else:
        f += 1
print(f)

Fixed submission:
n=int(input())
s=input()
r=g=b=0
for i in s:
  if i=="R":r+=1
  elif i=="G":g+=1
  else:b+=1

ans=r*g*b
for i in range(n):
  for j in range(i+1,n):
    k_ = j+(j-i)
    if(k_ >=n):
      break
    ans -= int(s[i]!= s[j] and s[i] != s[k_] and s[j] != s[k_])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
f=0
ijk = list()
for i in range(N):
    for j in range(N):
        for k in range(N):
            if(i<j<k):
                if(S[i]==S[j]):
                    pass
                elif(S[i]==S[k]):
                    pass
                elif(S[j]==S[k]):
                    pass
                else:
                    ijk.append([i+1,j+1,k+1])
# print(ijk)
for i in range(len(ijk)):
    if(ijk[i][1]-ijk[i][0] != ijk[i][2]-ijk[i][1]):
        f+=1
print(f)

Fixed submission:
n=int(input())
s=input()
r=g=b=0
for i in s:
  if i=="R":r+=1
  elif i=="G":g+=1
  else:b+=1

ans=r*g*b
for i in range(n):
  for j in range(i+1,n):
    k_ = j+(j-i)
    if(k_ >=n):
      break
    ans -= int(s[i]!= s[j] and s[i] != s[k_] and s[j] != s[k_])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
f=0
ijk = [[i+1,j+1,k+1] for i in range(N) for j in range(N) for k in range(N) 
        if i<j<k 
        if S[i]!=S[j] and
           S[i]!=S[k] and
           S[j]!=S[k]]
# print(ijk)
for i in range(len(ijk)):
    if(ijk[i][1]-ijk[i][0] != ijk[i][2]-ijk[i][1]):
        f+=1
print(f)

Fixed submission:
n=int(input())
s=input()
r=g=b=0
for i in s:
  if i=="R":r+=1
  elif i=="G":g+=1
  else:b+=1

ans=r*g*b
for i in range(n):
  for j in range(i+1,n):
    k_ = j+(j-i)
    if(k_ >=n):
      break
    ans -= int(s[i]!= s[j] and s[i] != s[k_] and s[j] != s[k_])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
f=0
ijk = list()
for i in range(N):
    for j in range(N):
        for k in range(N):
            if(i<j<k):
                if(S[i]!=S[j] and
                    S[i]!=S[k] and
                    S[j]!=S[k]):
                        ijk.append([i+1,j+1,k+1])
# print(ijk)
for i in range(len(ijk)):
    if(ijk[i][1]-ijk[i][0] != ijk[i][2]-ijk[i][1]):
        f+=1
print(f)

Fixed submission:
n=int(input())
s=input()
r=g=b=0
for i in s:
  if i=="R":r+=1
  elif i=="G":g+=1
  else:b+=1

ans=r*g*b
for i in range(n):
  for j in range(i+1,n):
    k_ = j+(j-i)
    if(k_ >=n):
      break
    ans -= int(s[i]!= s[j] and s[i] != s[k_] and s[j] != s[k_])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(input())
f=0
i_c = j_c = k_c =1
ijk = list()
for i in range(N):
    for j in range(N):
        for k in range(N):
            if(k_c>j_c and j_c>i_c):
                if(j_c-i_c!=k_c-j_c):
                    ijk.append([i,j,k])
            k_c+=1
        j_c+=1
        k_c = 1
    i_c+=1
    j_c = 1
for i in range(len(ijk)):
    if(S[ijk[i][0]]!= S[ijk[i][1]] and
       S[ijk[i][0]]!= S[ijk[i][2]] and
       S[ijk[i][1]]!= S[ijk[i][2]]):
       f+=1
print(f)

Fixed submission:
n=int(input())
s=input()
r=g=b=0
for i in s:
  if i=="R":r+=1
  elif i=="G":g+=1
  else:b+=1

ans=r*g*b
for i in range(n):
  for j in range(i+1,n):
    k_ = j+(j-i)
    if(k_ >=n):
      break
    ans -= int(s[i]!= s[j] and s[i] != s[k_] and s[j] != s[k_])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(map(str, input()))
f=0
i_c = j_c = k_c =1
ijk = list()
for i in range(N):
    for j in range(N):
        for k in range(N):
            if(k_c>j_c and j_c>i_c):
                if(j_c-i_c!=k_c-j_c):
                    ijk.append([i,j,k])
            k_c+=1
        j_c+=1
        k_c = 1
    i_c+=1
    j_c = 1
for i in range(len(ijk)):
    if(S[ijk[i][0]]!= S[ijk[i][1]] and
       S[ijk[i][0]]!= S[ijk[i][2]] and
       S[ijk[i][1]]!= S[ijk[i][2]]):
       f+=1
print(f)

Fixed submission:
n=int(input())
s=input()
r=g=b=0
for i in s:
  if i=="R":r+=1
  elif i=="G":g+=1
  else:b+=1

ans=r*g*b
for i in range(n):
  for j in range(i+1,n):
    k_ = j+(j-i)
    if(k_ >=n):
      break
    ans -= int(s[i]!= s[j] and s[i] != s[k_] and s[j] != s[k_])

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(map(str, input()))
f=0
i_c = j_c = k_c =1
ijk = list()
for i in range(N):
    for j in range(N):
        for k in range(N):
            if(k_c>j_c and j_c>i_c):
                if(j_c-i_c!=k_c-j_c):
                    ijk.append([i,j,k])
            k_c+=1
        j_c+=1
        k_c = 1
    i_c+=1
    j_c = 1
S_i = ijk[i][0]
S_j = ijk[i][1]
S_k = ijk[i][2]
for i in range(len(ijk)):
    if(S[ijk[i][0]]!= S[ijk[i][1]] and
       S[ijk[i][0]]!= S[ijk[i][2]] and
       S[ijk[i][1]]!= S[ijk[i][2]]):
       f+=1
print(f)

Fixed submission:
n=int(input())
s=input()
r=g=b=0
for i in s:
  if i=="R":r+=1
  elif i=="G":g+=1
  else:b+=1

ans=r*g*b
for i in range(n):
  for j in range(i+1,n):
    k_ = j+(j-i)
    if(k_ >=n):
      break
    ans -= int(s[i]!= s[j] and s[i] != s[k_] and s[j] != s[k_])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(map(str, input()))
f=0
i_c = j_c = k_c =1
for i in range(N):
    for j in range(N):
        for k in range(N):
            if(k_c>j_c and j_c>i_c):
                if(j_c-i_c!=k_c-j_c):
                    if(
                        S[i]!=S[j] and 
                        S[i]!=S[k] and
                        S[j]!=S[k]):
                        # print("!!",i,j,k)
                        f+=1
                        # print(i_c,j_c,k_c)
            k_c+=1
        j_c+=1
        k_c = 1
    i_c+=1
    j_c = 1

print(f)

Fixed submission:
n=int(input())
s=input()
r=g=b=0
for i in s:
  if i=="R":r+=1
  elif i=="G":g+=1
  else:b+=1

ans=r*g*b
for i in range(n):
  for j in range(i+1,n):
    k_ = j+(j-i)
    if(k_ >=n):
      break
    ans -= int(s[i]!= s[j] and s[i] != s[k_] and s[j] != s[k_])

print(ans)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = list(map(str, input()))
f=0
i_c = j_c = k_c =1
for i in range(N):
    for j in range(N):
        for k in range(N):
            if(k+1>j+1 and
               j+1>i+1 and
               j-i=k-j and
               S[i]!=S[j] and 
               S[i]!=S[k] and
               S[j]!=S[k]):
                    f+=1
 
print(f)

Fixed submission:
n=int(input())
s=input()
r=g=b=0
for i in s:
  if i=="R":r+=1
  elif i=="G":g+=1
  else:b+=1

ans=r*g*b
for i in range(n):
  for j in range(i+1,n):
    k_ = j+(j-i)
    if(k_ >=n):
      break
    ans -= int(s[i]!= s[j] and s[i] != s[k_] and s[j] != s[k_])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(map(str, input()))
f=0
i_c = j_c = k_c =1
for i in range(N):
    for j in range(N):
        for k in range(N):
            if(k+1>j+1 and
               j+1>i+1 and
               j-i!=k-j and
               S[i]!=S[j] and 
               S[i]!=S[k] and
               S[j]!=S[k]):
                    f+=1
 
print(f)

Fixed submission:
n=int(input())
s=input()
r=g=b=0
for i in s:
  if i=="R":r+=1
  elif i=="G":g+=1
  else:b+=1

ans=r*g*b
for i in range(n):
  for j in range(i+1,n):
    k_ = j+(j-i)
    if(k_ >=n):
      break
    ans -= int(s[i]!= s[j] and s[i] != s[k_] and s[j] != s[k_])

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(map(str, input()))
f=0
i_c = j_c = k_c =1
for i in range(N):
    for j in range(N):
        for k in range(N):
            if(k_c>j_c and j_c>i_c):
                if(j_c-i_c!=k_c-j_c):
                    if(
                        S[i]!=S[j] and 
                        S[i]!=S[k] and
                        S[j]!=S[k]):
                        # print("!!",i,j,k)
                        f+=1
                        # print(i_c,j_c,k_c)
            k_c+=1
        j_c+=1
        k_c = 1
    i_c+=1
    j_c = 1

print(f)

Fixed submission:
n=int(input())
s=input()
r=g=b=0
for i in s:
  if i=="R":r+=1
  elif i=="G":g+=1
  else:b+=1

ans=r*g*b
for i in range(n):
  for j in range(i+1,n):
    k_ = j+(j-i)
    if(k_ >=n):
      break
    ans -= int(s[i]!= s[j] and s[i] != s[k_] and s[j] != s[k_])

print(ans)