ZhenlongDai/ACPR huggingface dataset:
Problem: p02714
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
if __name__ == '__main__':
    N = int(input())
    S = input()
    cnt = 0
    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+2, N):
                if (S[i] != S[j] and S[i] != S[k] and S[j] != S[k]) and j - i != k - j:
                    cnt += 1
    print(cnt)

Failing test case input:
39
RRRBGRBGGBBRRGBBRGBBGGBRBRBRBGBBBBBGBBR

Expected output:
1806


Actual output:
1667


Fixed submission (verdict: Accepted):
from collections import Counter

def get_k(i, j):
    return 2*j - i

if __name__ == '__main__':
    N = int(input())
    S = input()
    C = Counter(S) 
    eq_cnt = 0
    cnt = C['R'] * C['G'] * C['B']
    for i in range(N):
        for j in range(i+1, N):
            k = get_k(i, j)
            if k >= N: continue
            if (S[i] != S[j] and S[i] != S[k] and S[j] != S[k]):
                eq_cnt += 1
    print(cnt - eq_cnt)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
S = list(input())
A = S.count("R") * S.count("G") * S.count("B")

for i in range(N):
  for j in range(N):
    k = j-i+j
    if k<N and S[k] != S[j] and S[k] != S[i] and S[i] !=S[j]:
      A -= 1    

print(A)


    




Failing test case input:
39
RBBGBBBBBGBRRBBRBGGBRGRBBGRRBBGGBRGBBRR

Expected output:
1808


Actual output:
1661


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
A = S.count("R") * S.count("G") * S.count("B")

for i in range(N):
  for j in range(i+1, N):
    k = j-i+j
    if k<N and S[k] != S[j] and S[k] != S[i] and S[i] !=S[j]:
      A -= 1    

print(A)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()

R = []
G = []
B = []
for i in range(n):
    if(s[i] == 'R'):
        R.append(i)
    elif(s[i] == 'G'):
        G.append(i)
    else:
        B.append(i)

samu = len(R) * len(G) * len(B)

for i in R:
    for j in G:
        k = 2 * j - i
        if(k in B):
            samu -= 1
        k = (i + j) / 2
        if(k in B):
            samu -= 1

print(samu)

Failing test case input:
39
RBBGRBBBBGBBBBBBBGGBBGRBBRRRRBGGBRGGRRR

Expected output:
1824


Actual output:
1840


Fixed submission (verdict: Accepted):
n = int(input())
s = input()

R = []
G = []
B = []
for i in range(n):
    if(s[i] == 'R'):
        R.append(i)
    elif(s[i] == 'G'):
        G.append(i)
    else:
        B.append(i)

samu = len(R) * len(G) * len(B)

for i in R:
    for j in G:
        k = int(2 * j - i)
        if(0 <= k < n):
            if(s[k] == 'B'):
                samu -= 1
        k = int(2 * i - j)
        if(0 <= k < n):
            if(s[k] == 'B'):
                samu -= 1
        if(i % 2 == j % 2):
            k = int((i + j) / 2)
            if(s[k] == 'B'):
                samu -= 1

print(samu)
Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
S = str(input())
R,G,B = 0,0,0
for i in range(N):
    if S[i] == 'R':
        R += 1
    elif S[i] == 'B':
        B += 1
    else:
        G += 1

exc = 0
for j in range(2,N-1):
    num = 1
    while 0 <= j-num and j+num < N:
        if S[j-num] != S[j+num] and  S[j-num] != S[j] and  S[j] != S[j+num]:
            exc += 1
        num += 1

print(int(R*B*G - exc))

Failing test case input:
39
RGBGBBBBBRBBBGBRBGGBBGRBBGRRBBGRRRGBBRR

Expected output:
1812


Actual output:
1813


Fixed submission (verdict: Accepted):
N = int(input())
S = str(input())
R,G,B = 0,0,0
for i in range(N):
    if S[i] == 'R':
        R += 1
    elif S[i] == 'B':
        B += 1
    else:
        G += 1

exc = 0
for j in range(1,N-1):
    num = 1
    while 0 <= j-num and j+num < N:
        if S[j-num] != S[j+num] and  S[j-num] != S[j] and  S[j] != S[j+num]:
            exc += 1
        num += 1

print(int(R*B*G - exc))

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()

ans = s.count('R') * s.count('G') * s.count('B')
print(ans)
for i in range(n):
    for j in range(i + 1, n):
        k = 2 * j - i
        
        if k < n and (s[i] != s[j] and s[j] != s[k]
                      and s[i] != s[k]) and j - i == k - j:
            ans -= 1

print(ans)


Failing test case input:
39
RBBGBBBBBGBRBRBRBGGBBGRBBGRRBBGGRRGBBRR

Expected output:
1803


Actual output:
1881
1803


Fixed submission (verdict: Accepted):
n = int(input())
s = input()

ans = s.count('R') * s.count('G') * s.count('B')

for i in range(n):
    for j in range(i + 1, n):
        k = 2 * j - i
        
        if k < n and (s[i] != s[j] and s[j] != s[k]
                      and s[i] != s[k]) and j - i == k - j:
            ans -= 1

print(ans)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
S = input()
ans, gap = S.count('R') * S.count('G') * S.count('B'), 1
while gap * 2 + 1 < N:
    ans -= sum([1 for i in range(N - gap * 2)
                if {'R', 'G', 'B'} == {S[i], S[i + gap], S[i + 2 * gap]}])
    gap += 1
print(ans)


Failing test case input:
39
RRGRRRBGGBBRRBBBRRBBRGBBBBBRBGBGGBBGBBG

Expected output:
1827


Actual output:
1828


Fixed submission (verdict: Accepted):
N = int(input())
S = input()
ans, gap = S.count('R') * S.count('G') * S.count('B'), 1
while gap * 2 + 1 <= N:
    ans -= sum([1 for i in range(N - gap * 2)
                if {'R', 'G', 'B'} == {S[i], S[i + gap], S[i + 2 * gap]}])
    gap += 1
print(ans)
Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N= int(input())
S=input()
r=[]
g=[]
b=[]
A=0
B=0
C=0
for i in range(N):
    if S[i]=="R":
        r.append(i)
        A+=1
    elif S[i]=="G":
        g.append(i)
        B+=1
    else:
        b.append(i)
        C+=1
k=0
for i in r:
    x=i
    for j in b:
        y=j
        if 2*x-y in b:
            k+=1
        if 2*y-x in b:
            k+=1
        if (x+y)/2 in b:
            k+=1

print(A*B*C-k)

Failing test case input:
39
RBBGBBBBBGBRBRBRBBGBBGRBGGRRBBGGBRGBRRR

Expected output:
1808


Actual output:
1729


Fixed submission (verdict: Accepted):
N= int(input())
S=input()
r=[]
g=[]
b=[]
A=0
B=0
C=0
for i in range(N):
    if S[i]=="R":
        r.append(i)
        A+=1
    elif S[i]=="G":
        g.append(i)
        B+=1
    else:
        b.append(i)
        C+=1
k=0
for i in range(N-2):
    for j in range(i+1,N-1):
        t=2*j-i
        if t<N:
            if S[i]!=S[j] and S[i]!=S[t] and S[t]!=S[j] :
                k+=1

print(A*B*C-k)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math
n =  int(input())
s = list(input())

upper = s.count("R")*s.count("G")*s.count("B")

minus = [0]*(n+1)
if s[0]!=s[1] and s[1]!=s[2] and s[2]!=s[0]:
  minus [3] = 1
else:
  minus [3] = 0

def counting(x):
  count = 0
  for i in range(math.ceil(x/2)):
    if s[x-1]!=s[x-1-i] and s[x-1-i]!=s[x-1-2*i] and s[x-1-2*i]!=s[x-1]:
      count += 1
    else:
      count += 0
  return count

for i in range(4,n):
  minus[i+1] = minus[i]+counting(i+1)

print(int(upper-minus[n]))

Failing test case input:
4
RBRG

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
import math
n =  int(input())
s = list(input())

upper = s.count("R")*s.count("G")*s.count("B")

def counting(x):
  count = 0
  for i in range(1, math.ceil(x/2)):
    if s[x-1]!=s[x-1-i] and s[x-1-i]!=s[x-1-2*i] and s[x-1-2*i]!=s[x-1]:
      count += 1
    else:
      count += 0
  return count

if n>=3:
  minus = [0]*(n+1)
  if s[0]!=s[1] and s[1]!=s[2] and s[2]!=s[0]:
    minus [3] = 1
  else:
    minus [3] = 0
  for i in range(3,n):
    minus[i+1] = minus[i]+counting(i+1)
  print(int(upper-minus[n]))
else:
  print(int(0))

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
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(0,n-2):
    for j in range(1,int(n/2)):
        if i + j + j <= n-1:
            if s[i] != s[i+j] and s[i] != s[i+j+j] and s[i+j] != s[i+j+j] :
                ans = ans - 1

print(ans)

Failing test case input:
39
RRGRRRBGGBBRRBBBRRBBRGBBBBBRBGBGGBBGBBG

Expected output:
1827


Actual output:
1828


Fixed submission (verdict: Accepted):
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(0,n-2):
    for j in range(1,int((n-i)/2)+1):
        if i + j + j <= n-1:
            if s[i] != s[i+j] and s[i] != s[i+j+j] and s[i+j] != s[i+j+j] :
                ans = ans - 1

print(ans)
Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()

count = 0
r=0
g=0
b=0
for i in range(0,n):
  if s[i] == 'R':
    r = r + 1
  if s[i]=='G':
    g = g+1
  if s[i]=='B':
    b = b+1
    
for i in range(0,n-3):
  ii = s[i]
  for j in range(i+1, n-1):
    jj = s[j]
    if ii==jj:
      continue
    if (2*j-i)<=(n-1):
      if ii!=s[2*j-i] and jj!=s[2*j-i]:
        count = count + 1
print(r*g*b-count)


Failing test case input:
4
RGRB

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
n = int(input())
s = input()

count = 0
r=0
g=0
b=0
for i in range(0,n):
  if s[i] == 'R':
    r = r + 1
  if s[i]=='G':
    g = g+1
  if s[i]=='B':
    b = b+1
    
for i in range(0,n):
  ii = s[i]
  for j in range(i+1, n):
    jj = s[j]
    if ii==jj:
      continue
    if (2*j-i)<=(n-1):
      if ii!=s[2*j-i] and jj!=s[2*j-i]:
        count = count + 1
print(r*g*b-count)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()

R=[]
G=[]
B=[]

for i in range(n):
    if s[i] == "R":
        R.append(i)
    elif s[i] == "G":
        G.append(i)
    else:
        B.append(i)

ans = len(R)*len(G)*len(B)
for i in range(n-2):
    for j in range(i+1,n-1):
        k  = 2*j-i
        if k<n:
            if (s[i]==s[j]) and (s[i]==s[k]) and (s[j]==s[k]):
                ans-=1
print(ans)

Failing test case input:
39
RRRBGRBGGBBRBGGBRGBBGBBRBRBRBGBBBBBGBRR

Expected output:
1803


Actual output:
1826


Fixed submission (verdict: Accepted):
n = int(input())
s = input()

R=[]
G=[]
B=[]

for i in range(n):
    if s[i] == "R":
        R.append(i)
    elif s[i] == "G":
        G.append(i)
    else:
        B.append(i)

ans = len(R)*len(G)*len(B)
for i in range(n-2):
    for j in range(i+1,n-1):
        k  = 2*j-i
        if k<n:
            if (s[i]!=s[j]) and (s[i]!=s[k]) and (s[j]!=s[k]):
                ans-=1
print(ans)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()

r_count = s.count('R')
g_count = s.count('G')
b_count = s.count('B')

discount = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        k = i + 2*(j-i)
        if k > n-1:
            break
        if s[i] == s[j] or s[i] == s[k] or s[j] == s[k]:
            discount += 1
print(r_count*g_count*b_count-discount)

Failing test case input:
39
RBBGBBBBBGRRBRBRBGGBBGRBBGBRBBGGBRGBRRR

Expected output:
1803


Actual output:
1598


Fixed submission (verdict: Accepted):
n = int(input())
s = input()

r_count = s.count('R')
g_count = s.count('G')
b_count = s.count('B')

discount = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        k = i + 2*(j-i)
        if k > n-1:
            break
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            discount += 1

print(r_count*g_count*b_count-discount)
Problem: p02714
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())
s=list(input())
a=s.count("R")
b=s.count("G")
c=s.count("B")
print(a*b*c)
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    k=2*j-i
    if n-1>=k and not(s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]):
        ans=ans+1
print(a*b*c-ans)


Failing test case input:
4
BRRG

Expected output:
2


Actual output:
2
0


Fixed submission (verdict: Accepted):
n=int(input())
s=list(input())
a=s.count("R")
b=s.count("G")
c=s.count("B")
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    k=2*j-i
    if n-1>=k and (s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]): 
      ans=ans+1
print(a*b*c-ans)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
R = []
G = []
B = []
s =input()
ans = 0
for i in range(N):
    if s[i] == "R":
        R.append(i)
    elif s[i] == "G":
        G.append(i)
    else:
        B.append(i)
sB = set(B)
print(sB)
ans = len(R) * len(G) * len(B)
for r in R:
    for g in G:
        i = min(r,g)
        j = max(r,g)
        sa = j - i
        if i - sa in sB:
            ans -= 1
        if j + sa in sB:
            ans -= 1
        if (i + j) / 2 in sB:
            ans -= 1
print(ans)

Failing test case input:
39
RGBGBBBBBRBBBRBRBGGBBGRBBGRRBBGGRRGBBRR

Expected output:
1810


Actual output:
{2, 4, 5, 6, 7, 8, 10, 11, 12, 14, 16, 19, 20, 23, 24, 28, 29, 35, 36}
1810


Fixed submission (verdict: Accepted):
N = int(input())
R = []
G = []
B = []
s =input()
ans = 0
for i in range(N):
    if s[i] == "R":
        R.append(i)
    elif s[i] == "G":
        G.append(i)
    else:
        B.append(i)
sB = set(B)
ans = len(R) * len(G) * len(B)
for r in R:
    for g in G:
        i = min(r,g)
        j = max(r,g)
        sa = j - i
        if i - sa in sB:
            ans -= 1
        if j + sa in sB:
            ans -= 1
        if (i + j) / 2 in sB:
            ans -= 1
print(ans)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()
ans = s.count("R") * s.count("G") * s.count("B")
cnt = 0
for i in range(n-3):
    i_ = s[i]
    for j in range(i+1, n-1):
        if s[j] == i_: continue
        k = 2 * j - i
        j_ = s[j]
        if k >= n or s[k] == i_ or s[k] == j_: continue
        cnt += 1
print(ans - cnt)

Failing test case input:
39
RGBBGRRGGBBRRGBBRRBBGGBRBRBBBRBBBBBGBGR

Expected output:
1807


Actual output:
1808


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
ans = s.count("R") * s.count("G") * s.count("B")
cnt = 0
for i in range(n):
    i_ = s[i]
    for j in range(i+1, n):
        if s[j] == i_: continue
        k = 2 * j - i
        j_ = s[j]
        if k >= n or s[k] == i_ or s[k] == j_: continue
        cnt += 1
print(ans - cnt)
Problem: p02714
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n,s=open(0)
n=int(n)
s=[ord(c)%3for c in s]
d=[0]*3
for i in s:d[i]+=1
a=0
for i in range(n):
    d[s[i]]-=1
    b=d.copy()
    for j in range(i+1,n):
        b[s[j]]-=1
        if s[i]==s[j]:continue
        c=(0,2,1,0)[s[i]+s[j]]
        a+=b[c]
        k=j+j-i
        if k<n and s[k]==c:
            a-=1
print(a)

Failing test case input:
39
RRRRGRBGGBBRBGGBBGBBGBBRBRBRBGBBBBBGBRR

Expected output:
1819


Actual output:
1990


Fixed submission (verdict: Accepted):
n=int(input())
s=[ord(c)%3for c in input()]
d=[0]*3
for i in s:d[i]+=1
a=0
for i in range(n):
    d[s[i]]-=1
    b=d.copy()
    for j in range(i+1,n):
        b[s[j]]-=1
        if s[i]==s[j]:continue
        c=(0,2,1,0)[s[i]+s[j]]
        a+=b[c]
        k=j+j-i
        if k<n and s[k]==c:
            a-=1
print(a)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
S=str(input())

r=S.count('R')
g=S.count('G')
b=S.count('B')

ans=r*g*b
dib=0
m=0

for i in range(N-2):
    m=(N-i)
    for j in range(i+1,m):
            dib=j-i
            if j+dib<=N-1:
                if S[i]!=S[j] and S[i]!=S[j+dib] and S[j]!=S[j+dib]:
                    ans=ans-1
            
print(ans)

Failing test case input:
39
RBRBGRBGGBBRRGBBRRRBGGBRBGBRBGBRBBBGBBB

Expected output:
1800

Actual output:
1823


Fixed submission (verdict: Accepted):
N=int(input())
S=str(input())

r=S.count('R')
g=S.count('G')
b=S.count('B')


ans=r*g*b
dib=0
m=0

for i in range(N-2):
    m=(N+i)
    for j in range(i+1,m):
            dib=j-i
            if j+dib<=N-1:
                if S[i]!=S[j] and S[i]!=S[j+dib] and S[j]!=S[j+dib]:
                    ans=ans-1
            
print(ans)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import collections

n=int(input())
S=input()
s=collections.Counter(S)
print(s)
ans=s['R']*s['G']*s['B']
for i in range(n):
    for d in range(n):
        j=i+d
        k=j+d
        if k>n-1:
            break
        if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            ans-=1
print(ans)

Failing test case input:
39
BBBGBBBRBGBRBGBRBGGBRRRBGBRRBBGGBRGBRBR

Expected output:
1804


Actual output:
Counter({'B': 19, 'R': 11, 'G': 9})
1804


Fixed submission (verdict: Accepted):



import collections

n=int(input())
S=input()
s=collections.Counter(S)
ans=s['R']*s['G']*s['B']
for i in range(n):
    for d in range(n):
        j=i+d
        k=j+d
        if k>n-1:
            break
        if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
            ans-=1
print(ans)
Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
S=list(input())
a=[0]*4

for i in range(N):
  if S[i]=='R':a[0]+=1
  if S[i]=='G':a[1]+=1
  if S[i]=='B':a[2]+=1
    
for i in range(N):
  for j in range(i+1,N):
    k=j+(j-i)
    if k>=N:
      break
    else:
      if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i] and j-i==k-j:
        a[3]+=1

print(a)
print(a[0]*a[1]*a[2]-a[3])

Failing test case input:
39
RBBGBBBBBGBBBRGRBBGBBGRBGGRRBBGGBRRBRRR

Expected output:
1810


Actual output:
[11, 9, 19, 71]
1810


Fixed submission (verdict: Accepted):
N=int(input())
S=list(input())
a=[0]*4

for i in range(N):
  if S[i]=='R':a[0]+=1
  if S[i]=='G':a[1]+=1
  if S[i]=='B':a[2]+=1
    
for i in range(N):
  for j in range(i+1,N):
    k=j+(j-i)
    if k>=N:
      break
    else:
      if S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i] and j-i==k-j:
        a[3]+=1

print(a[0]*a[1]*a[2]-a[3])

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()

r_count = s.count('R')
g_count = s.count('G')
b_count = s.count('B')

discount = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        k = i + 2*(j-i)
        if k > n-1:
            break
        if s[i] == s[j] and s[i] == s[k]:
            print(str(i)+str(j)+str(k)+s[i] + s[j] + s[k])
            discount += 1

print(r_count*g_count*b_count-discount)

Failing test case input:
39
RRGBGRBGGBBRRGBBRBRBRGBRBGBRBGBBBBBGBBR

Expected output:
1810


Actual output:
11223RRR
369BBB
3915BBB
31017BBB
31731BBB
51627RRR
61014BBB
61422BBB
61524BBB
61728BBB
61932BBB
72135GGG
91419BBB
101724BBB
101928BBB
102234BBB
121620RRR
132129GGG
141924BBB
142230BBB
142434BBB
151719BBB
152433BBB
152637BBB
161820RRR
162738RRR
172431BBB
192633BBB
192837BBB
212529GGG
222426BBB
222630BBB
222834BBB
242628BBB
242832BBB
243036BBB
262830BBB
263034BBB
263136BBB
283032BBB
283134BBB
283236BBB
303132BBB
303234BBB
303336BBB
313233BBB
313437BBB
323334BBB
323436BBB
1832


Fixed submission (verdict: Accepted):
n = int(input())
s = input()

r_count = s.count('R')
g_count = s.count('G')
b_count = s.count('B')

discount = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        k = i + 2*(j-i)
        if k > n-1:
            break
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            discount += 1

print(r_count*g_count*b_count-discount)
Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import itertools

N = int(input())
S = input()

r = len(list(filter(lambda x: x == "R", S)))
g = len(list(filter(lambda x: x == "G", S)))
b = len(list(filter(lambda x: x == "B", S)))



ans = r * g * b
RGB = list(itertools.permutations(["R", "G", "B"], 3))



for i in range(1, N):
    for j in range(1, N-i*2):
        if (S[j], S[j+i], S[j+2*i]) in RGB:
            ans -= 1

print(ans)


Failing test case input:
39
RBRBGRBRGBBRBGBBRRRBGGBRBGBRBGBRBBBGGBB

Expected output:
1799


Actual output:
1801


Fixed submission (verdict: Accepted):
import itertools

N = int(input())
S = input()

r = len(list(filter(lambda x: x == "R", S)))
g = len(list(filter(lambda x: x == "G", S)))
b = len(list(filter(lambda x: x == "B", S)))



ans = r * g * b
RGB = list(itertools.permutations(["R", "G", "B"], 3))



for i in range(1, N):
    for j in range(N-i*2):
        if (S[j], S[j+i], S[j+2*i]) in RGB:
            ans -= 1

print(ans)

Problem: p02714
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())
s=input()
dict={}
dict["R"]=[]
dict["G"]=[]
dict["B"]=[]
res=0
for i in range(n):
  if s[i]=="R":
    dict["R"].append(i)
  elif s[i]=="G":
    dict["G"].append(i)
  elif s[i]=="B":
    dict["B"].append(i)
  else:
    raise Exception
for r in dict["R"]:
  for g in dict["G"]:
    if r<g:
      for b in dict["B"]:
        if g<b:
          if 2*r!=g+b and 2*g!=r+b and 2*b!=r+g:
            res+=1           
print(res)

Failing test case input:
39
BBBGBBRRBGBRBGBRBGGBRRRBGBRRBBGGBRGBBBR

Expected output:
1803


Actual output:
270


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
dict={}
dict["R"]=[]
dict["G"]=[]
dict["B"]=[]
for i in range(n):
  if s[i]=="R":
    dict["R"].append(i)
  elif s[i]=="G":
    dict["G"].append(i)
  elif s[i]=="B":
    dict["B"].append(i)
  else:
    raise Exception
res=len(dict["R"])*len(dict["G"])*len(dict["B"])
for r in dict["R"]:
  for g in dict["G"]:
      if (r+g)%2==0:
        if s[(r+g)
          res-=1
      try:
        if s[2*r-g]=="B" and 2*r-g>=0:
          	res-=1
      except:pass
      try:
        if s[2*g-r]=="B" and 2*g-r>=0:
          res-=1
      except:pass      
      
print(res)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

n=int(input())
s=input()

kumikazu = s.count('R')*s.count('B')*s.count('G')

for i in range(n-2):
    for j in range(n-1):
        k = 2*j-i
        if k > n-1:
            break
        if (s[i] != s[j]) and (s[i] != s[k]) and (s[j] != s[k]):
            kumikazu -= 1

print(kumikazu)



Failing test case input:
39
RRRBGRBGGBRRRGBBBRBBGGBRBGBRBGBBBBBGBBR

Expected output:
1812


Actual output:
1664


Fixed submission (verdict: Accepted):
n = int(input())
s = input()

kumikazu = s.count('R')*s.count('B')*s.count('G')

for i in range(n-2):
    for j in range(i+1, n-1):
        k = 2*j-i
        if k >= n:
          break
        if (s[i] != s[j]) and (s[i] != s[k]) and (s[j] != s[k]):
                kumikazu -= 1
print(kumikazu)
Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = list(input())
cnt = 0

cnt = s.count("R") * s.count("B") * s.count("G")
print(cnt)

sub = 0 
for i in range(n):
    for j in range(i, n):
        k = 2 * j - i
        if k <= n - 1:
            if (s[i] != s[j]) and (s[j] != s[k]) and (s[i] != s[k]):
                sub += 1

print(cnt-sub)

Failing test case input:
39
RBBGBBBBBGBRBRBRBGGBBGRBBGRRBBGGBRGBRRR

Expected output:
1806


Actual output:
1881
1806


Fixed submission (verdict: Accepted):
n = int(input())
s = list(input())
cnt = 0

cnt = s.count("R") * s.count("B") * s.count("G")

sub = 0 
for i in range(n):
    for j in range(i, n):
        k = 2 * j - i
        if k <= n - 1:
            if (s[i] != s[j]) and (s[j] != s[k]) and (s[i] != s[k]):
                sub += 1

print(cnt-sub)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
S = str(input())
R,G,B = 0,0,0
for i in range(N):
    if S[i] == 'R':
        R += 1
    elif S[i] == 'B':
        B += 1
    else:
        G += 1

exc = 0
for j in range(2,N-1):
    num = 1
    while 0 <= j-num and j+num < N:
        if S[j-num] != S[j+num] and  S[j-num] != S[j] and  S[j] != S[j+num]:
            exc += 1
        num += 1

print(R*B*G - exc)

Failing test case input:
39
GBRBRRBGGBBRRRBBGRRBGGBRBGBRBGBRBBBGBBB

Expected output:
1791


Actual output:
1792


Fixed submission (verdict: Accepted):
N = int(input())
S = str(input())
R,G,B = 0,0,0
for i in range(N):
    if S[i] == 'R':
        R += 1
    elif S[i] == 'B':
        B += 1
    else:
        G += 1

exc = 0
for j in range(1,N-1):
    num = 1
    while 0 <= j-num and j+num < N:
        if S[j-num] != S[j+num] and  S[j-num] != S[j] and  S[j] != S[j+num]:
            exc += 1
        num += 1

print(int(R*B*G - exc))

Problem: p02714
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n = int(input())
s = input()
S = list(s)
r = S.count('R')
g = S.count('G')
b = S.count('B')
ans = r * g * b
for k in range(n):
        for j in range(k):
            i = 2*j - k
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1
print(ans)

Failing test case input:
39
RRBBGRBGGBBRRGBBRGRBGGBRBBRRBGBBBBBGBBR

Expected output:
1808


Actual output:
1734


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
S = list(s)
r = S.count('R')
g = S.count('G')
b = S.count('B')
ans = r * g * b
for k in range(n):
        for j in range(k):
            i = 2*j - k
            if i >= 0 and i < j and S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                ans -= 1
print(ans)
Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()
r = s.count("R")
g = s.count("G")
b = s.count("B")
num = 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] and s[j] != s[k] and s[k] != s[i]:
            n

Failing test case input:
39
RRRBGRBGGBBRBGGBRGBBGBBRBRBRBGBBBBBGBRR

Expected output:
1803


Actual output:

Fixed submission (verdict: Accepted):
n = int(input())
s = input()
r = s.count("R")
g = s.count("G")
b = s.count("B")
num = 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] and s[j] != s[k] and s[k] != s[i]:
            num -=1
print(num)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):


n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

counter = r_cnt * g_cnt * b_cnt

for i in range(n):
    for p in range(n):
        j = i + p
        k = j + p
        if k >= n:
            break
        if s[i] != s[j] and s[i] != s[j] and s[i] != s[j]:
            counter -= 1
print(counter)

Failing test case input:
39
RRRBGRBGGBRRRGBBBBBBGGBRBGBRBGRBBBBGBBR

Expected output:
1814


Actual output:
1646


Fixed submission (verdict: Accepted):


n = int(input())
s = input()

r_cnt = s.count('R')
g_cnt = s.count('G')
b_cnt = s.count('B')

counter = r_cnt * g_cnt * b_cnt

for i in range(n):
    for p in range(n):
        j = i + p
        k = j + p
        if k >= n:
            break
        if s[i] != s[j] and s[j] != s[k] and s[k] != s[i]:
            counter -= 1
print(counter)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
S = input()

ans = 0

for i in range(N):
    for j in range(N):
        for k in range(N):
            if (j-i != k-j):
                if (i < j < k and S[i] != S[j] != S[k]):
                    ans += 1


print(ans)

Failing test case input:
39
RBRBGRBRGBBRBGBBRRRBGGBRBGBRBGBRBBBGGBB

Expected output:
1799


Actual output:
3797


Fixed submission (verdict: Accepted):
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-2):
    for j in range(i+1,N-1):
        k = 2*j-i
        if k < N and S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1

print(ans)

Problem: p02714
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())
s=list(input())
a=s.count("R")
b=s.count("G")
c=s.count("B")
print(a*b*c)
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    k=2*j-i
    if n-1>=k and (s[i]==s[j] or s[i]==s[k] or s[j]==s[k]):
        ans=ans+1
print(a*b*c-ans)


Failing test case input:
39
RBRBRRBGGBBRRGBBGRRBGGBRBGBRBGBRBBBGBBB

Expected output:
1796


Actual output:
1881
1605


Fixed submission (verdict: Accepted):
n=int(input())
s=list(input())
a=s.count("R")
b=s.count("G")
c=s.count("B")
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    k=2*j-i
    if n-1>=k and (s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]): 
      ans=ans+1
print(a*b*c-ans)
Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def main():
    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 j in range(i+1,n):
            if s[i] != s[j]:
                if 2*i-j < n:
                    if s[i]!=s[2*i-j] and s[j]!=s[2*i-j]:
                        ans-=1

    
    print(ans)
main()

Failing test case input:
39
BBBGBBBRBGBRBGBRBGGBRRRBBGRRBBGGBRGBRBR

Expected output:
1800


Actual output:
1718


Fixed submission (verdict: Accepted):
def main():
    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-2):
        for j in range(i+1,n-1):
            if s[i] != s[j]:
                if 2*j-i < n:
                    if s[i]!=s[2*j-i] and s[j]!=s[2*j-i]:
                        ans-=1

    
    print(ans)

main()

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
K = int(input())
S = list(input())
R = []
G = []
B = []
total = 0

for a in range(0,K):
  if S[a]=="R":
    R.append(a)
  elif S[a]=="G":
    G.append(a)
  else :
    B.append(a)

for a in R:
  for b in G:
    for c in B:
      tmp = [a,b,c]
      tmp.sort
      if a+b+c != 3*tmp[1]:
        total += 1
print(total)

Failing test case input:
39
RRRBGRBGGBBRRGBBRRBBGGBRBGBRBGBBBBBGBBR

Expected output:
1811


Actual output:
1855


Fixed submission (verdict: Accepted):
K = int(input())
S = list(input())
total = 0
R,G,B = 0,0,0

for a in range(0,K):
  if S[a]=="R":
    R += 1
  elif S[a]=="G":
    G += 1
  else :
    B += 1
    
total = R*G*B

for i in range(0,K):
  for j in range(i,K):
    k = 2*j-i
    if k<K:
      if S[i] != S[k] and S[i] != S[j] and S[j] != S[k]:
        total -= 1
print(total)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n= int(input())
ss=input()
rs = set()
gs = set()
bs = set()

for i, s in enumerate(ss):
    if s == "R":
        rs.add(i)
    elif s == "G":
        gs.add(i)
    else:
        bs.add(i)
ans = 0
if len(gs) > len(bs) and len(gs) > len(rs):
    tmp = gs
    gs = bs
    bs = tmp
elif len(rs) > len(bs) and len(rs) > len(gs):
    tmp =rs
    rs = bs
    bs = rs
    
for r in rs:
    for g in gs:
        c = 0
        if r+r-g in bs:
            c+=1
        if g+g-r in bs:
            c+=1
        if (g+r)/2 in bs:
            c+=1
        ans += len(bs) -c
print(ans)


Failing test case input:
4
BRRG

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
n= int(input())
ss=input()
rs = set()
gs = set()
bs = set()
 
for i, s in enumerate(ss):
    if s == "R":
        rs.add(i)
    elif s == "G":
        gs.add(i)
    else:
        bs.add(i)
ans = 0
if len(gs) > len(bs) and len(gs) > len(rs):
    tmp = gs
    gs = bs
    bs = tmp
elif len(rs) > len(bs) and len(rs) > len(gs):
    tmp =rs
    rs = bs
    bs = tmp
    
for r in rs:
    for g in gs:
        c = 0
        if r+r-g in bs:
            c+=1
        if g+g-r in bs:
            c+=1
        if (g+r)/2 in bs:
            c+=1
        ans += len(bs) -c
print(ans)
Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
s=input()
r=s.count('R')
g=s.count('G')
b=s.count('B')
cnt=0
for i in range(n-2):
    for j in range(1, min(i+1, n-i)):
            if (s[i] != s[i-j]) and (s[i] != s[i+j]) and (s[i-j] != s[i+j]):
                cnt += 1
print(r*g*b-cnt)

Failing test case input:
4
RRGB

Expected output:
1

Actual output:
2


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
r=s.count('R')
g=s.count('G')
b=s.count('B')
cnt=0
for i in range(n-1):
    for j in range(1, min(i+1, n-i)):
            if (s[i] != s[i-j]) and (s[i] != s[i+j]) and (s[i-j] != s[i+j]):
                cnt += 1
print(r*g*b-cnt)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
s=input()
r,g,b=0,0,0
for i in range(n):
    if s[i]=="R":
        r+=1
    elif s[i]=="G":
        g+=1
    else:
        b+=1
chohuku=0
double=0
for i in range(1,n-1):
    for j in range(1,min(i+1,n-1-i)):
        chohuku+=1
        k=j+i
        l=i-j
        if s[i]==s[k] or s[i]==s[l] or s[l]==s[k]:
            double+=1
ans=r*g*b-chohuku+double
print(ans)

Failing test case input:
39
RBRBRRBGGBBRRGBBGRRBGGBRBGBRBGBRBBBGBBB

Expected output:
1796


Actual output:
1801


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
r,g,b=0,0,0
for i in range(n):
    if s[i]=="R":
        r+=1
    elif s[i]=="G":
        g+=1
    else:
        b+=1
chohuku=0
double=0
for i in range(1,n-1):
    for j in range(1,min(i+1,n-i)):
        chohuku+=1
        k=j+i
        l=i-j
        if s[i]!=s[k] and s[i]!=s[l] and s[l]!=s[k]:
            double+=1
ans=r*g*b-double
print(ans)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()

r_count = s.count('R')
g_count = s.count('G')
b_count = s.count('B')

discount = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        k = i + 2*(j-i)
        if k > n-1:
            break
        if s[i] == s[j] and s[i] == s[k]:
            discount += 1

print(r_count*g_count*b_count-discount)

Failing test case input:
39
RRGBGRBGGBBRRGBBRBRBRGBRBGBRBGBBBBBGBBR

Expected output:
1810


Actual output:
1832


Fixed submission (verdict: Accepted):
n = int(input())
s = input()

r_count = s.count('R')
g_count = s.count('G')
b_count = s.count('B')

discount = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        k = i + 2*(j-i)
        if k > n-1:
            break
        if s[i] != s[j] and s[i] != s[k] and s[j] != s[k]:
            discount += 1

print(r_count*g_count*b_count-discount)
Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N=int(input())
S=input()

ans = S.count("R")*S.count("G")*S.count("B")

tmp=0

for i in range(N):
  for j in range(i,N):
    if j-i+j < N:
      if S[i]==S[j] and S[j]==S[j-i+j] and S[i]==S[j-i+j]:
        tmp += 1

ans = ans - tmp
print(ans)

Failing test case input:
39
BBRBRRBGGBBRRGBBGRRBGGBRRGBRBGBRBBBGBBB

Expected output:
1797


Actual output:
1795


Fixed submission (verdict: Accepted):
N=int(input())
S=input()

ans = S.count("R")*S.count("G")*S.count("B")

tmp=0

for i in range(N):
  for j in range(i,N):
    if j-i+j < N:
      if S[i]!=S[j] and S[j]!=S[j-i+j] and S[i]!=S[j-i+j]:
        tmp += 1

ans = ans - tmp
print(ans)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
a=int(input())
b=str(input())
sum=0

riron_sum=b.count('R')*b.count('G')*b.count('B')
print(riron_sum)
for i in range(0,a):
    for n in range(0,a+1):
        j = i+n
        k = j+n
        
        
        if k>=a:
        	break

        if b[i]!=b[j] and b[j]!=b[k] and b[k]!=b[i]:
                riron_sum-=1

print(riron_sum)

Failing test case input:
39
BBBGBBBRBGBRBGBRBGGBRBRBBGRRBBGGBRGBRRR

Expected output:
1804


Actual output:
1881
1804


Fixed submission (verdict: Accepted):
a=int(input())
b=str(input())
sum=0

riron_sum=b.count('R')*b.count('G')*b.count('B')

for i in range(0,a):
    for n in range(0,a+1):
        j = i+n
        k = j+n
        
        
        if k>=a:
        	break

        if b[i]!=b[j] and b[j]!=b[k] and b[k]!=b[i]:
                riron_sum-=1

print(riron_sum)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):


N = int(input())
S = input()
S = S[::-1]

cnt = S.count('B')*S.count('G')*S.count('R')






for i in range(1,N-1):
    for j in range(i+1,N):
        k = 2*j-i
        if k>j and k<=N:
            if S[i-1]==S[j-1] or S[i-1]==S[k-1] or S[j-1]==S[k-1] :
                cnt -= 1


print(cnt)

Failing test case input:
39
RRBBGRRGGBBRRGBBRGBBGGBRBRBGBRBBBBBGBBR

Expected output:
1807


Actual output:
1594


Fixed submission (verdict: Accepted):


N = int(input())
S = input()
S = S[::-1]

cnt = S.count('B')*S.count('G')*S.count('R')

for i in range(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] :
                cnt -= 1


print(cnt)
Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
S = input()
r = 0
g = 0
b = 0
k = 0
for i in range(N):
    if S[i] == "R":
        r += 1
    elif S[i] == "G":
        g += 1
    else:
        b += 1

sum = r * g * b
for i in range(0, N-2):
    for j in range(i+1,N-1):
        if 2*j - i < N:
            k = 2*j - i
        if S[j] == S[i] and S[k] == S[j]:
            sum -= 1

print(sum)


Failing test case input:
4
RRBG

Expected output:
1


Actual output:
2


Fixed submission (verdict: Accepted):
N = int(input())
S = "A"
S += input()
r = 0
g = 0
b = 0
k = 0
for i in range(1, N+1):
    if S[i] == "R":
        r += 1
    elif S[i] == "G":
        g += 1
    else:
        b += 1

sum = r * g * b
for i in range(1, N-1):
    for j in range(i+1,N):
        k = 2*j - i
        if k <= N:
            if S[j] != S[i] and S[k] != S[j] and S[i] != S[k]:
                sum -= 1

print(sum)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
A = int(input())
B = input()
count_r = B.count("R")
count_g = B.count("G")
count_b = B.count("B")
ans = count_b * count_g * count_r
for i in range(A):
    for j in range(A):
        d = i+j
        f = d+j
        if f >= A:
            break
        if B[i] != B[d] != B[f]:
            ans -= 1
print(ans)

Failing test case input:
39
RRGRRRBGGBBRRBBBRRBBRGBBBBBRBGBGGBBGBBG

Expected output:
1827


Actual output:
1757


Fixed submission (verdict: Accepted):
A = int(input())
B = input()
count_r = B.count("R")
count_g = B.count("G")
count_b = B.count("B")
ans = count_b * count_g * count_r
for i in range(A):
    for j in range(A):
        d = i+j
        f = d+j
        if f >= A:
            break
        if B[i] != B[d] and B[d] != B[f] and B[i] != B[f]:
            ans -= 1
print(ans)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()

nr = s.count("R")
ng = s.count("G")
nb = s.count("B")

count = nr * ng * nb

for i in range(n-3):
    for j in range(i+1, n-1):
        if s[i] == s[j]:continue
        else:
            k = 2*j - i 
            if k > n - 1:continue
            if s[i] == s[k]:continue
            if s[j] == s[k]:continue
            count -= 1

print(count)


Failing test case input:
39
RRBBGRRGGBBRRGBBRGBBGGBRBRBBBRBBBBBGBGR

Expected output:
1810


Actual output:
1811


Fixed submission (verdict: Accepted):
n = int(input())
s = input()

nr = s.count("R")
ng = s.count("G")
nb = s.count("B")

count = nr * ng * nb

for i in range(n-2):
    for j in range(i+1, (n+i+1)
        if s[i] == s[j]:continue
        else:
            k = 2*j - i 
            if s[i] == s[k]:continue
            if s[j] == s[k]:continue
            count -= 1

print(count)
Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()
r_num = s.count('R')
g_num = s.count('G')
b_num = s.count('B')
tot = r_num*g_num*b_num
print(tot)
for i in range(n):
    for j in range(i+1,n):
        k = j+(j-i)

        if k<n:
            if s[i]!=s[j] and s[i]!=s[k] and s[j] != s[k]:
                tot -= 1

print(tot)


Failing test case input:
39
BBBGBBBRBGBRBRGRBGGBRRGBBGRRBBGGBRRBRBB

Expected output:
1793


Actual output:
1881
1793


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
r_num = s.count('R')
g_num = s.count('G')
b_num = s.count('B')
tot = r_num*g_num*b_num
for i in range(n):
    for j in range(i+1,n):
        k = j+(j-i)

        if k<n:
            if s[i]!=s[j] and s[i]!=s[k] and s[j] != s[k]:
                tot -= 1

print(tot)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
S = input()

ans = S.count("R") * S.count("G") * S.count("B")

for i in range(N):
    for j in range(i+1,N):
        k = j-i+j
        if k<N and S[k]!=S[j] and S[k]!=S[j] and S[i]!=S[j]:
            ans -= 1

print(ans)

Failing test case input:
39
RRBBGRBGGBBRRGBBRGRBGGBRBBRBBGBRBBBGBBR

Expected output:
1811


Actual output:
1726


Fixed submission (verdict: Accepted):
N = int(input())
S = list(input())

ans = S.count("R") * S.count("G") * S.count("B")

for i in range(N):
    for j in range(i+1,N):
        k = j-i+j
        if k<N and S[k]!=S[i] and S[k]!=S[j] and S[i]!=S[j]:
            ans -= 1

print(ans)

Problem: p02714
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n=int(input())
s=input()
ans=0
a=min(s.count("R"),s.count("G"),s.count("B"))
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if s[j]!=s[i] and s[i]!=s[k] and s[j]!=s[k] and k+i!=2j:
                ans = ans+1
print(ans)

Failing test case input:
39
RBBGBBBBBGBRBRBBBGGBBGRBBGRRBBGGBRGRRRR

Expected output:
1811


Actual output:
1881


Fixed submission (verdict: Accepted):
n=int(input())
s=list(input())
a=s.count("R")
b=s.count("G")
c=s.count("B")
ans=0
for i in range(n-2):
  for j in range(i+1,n-1):
    k=2*j-i
    if n-1>=k and (s[i]!=s[j] and s[i]!=s[k] and s[j]!=s[k]): 
      ans=ans+1
print(a*b*c-ans)
Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
s=input()
r,g,b=0,0,0
for i in range(n):
    if s[i]=="R":
        r+=1
    elif s[i]=="G":
        g+=1
    else:
        b+=1
chohuku=0
double=0
for i in range(1,n-1):
    for j in range(1,min(i+1,n-i)):
        chohuku+=1
        k=j+i
        l=i-j
        if s[i]!=s[k] and s[i]!=s[l] and s[l]!=s[k]:
            double+=1
ans=r*g*b-double
print(r,g,b,ans)

Failing test case input:
39
BGRBRRBGGBBRRGBBGRRBGGBRRGBRBGBRBBBBBBB

Expected output:
1792


Actual output:
11 9 19 1792


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
r,g,b=0,0,0
for i in range(n):
    if s[i]=="R":
        r+=1
    elif s[i]=="G":
        g+=1
    else:
        b+=1
chohuku=0
double=0
for i in range(1,n-1):
    for j in range(1,min(i+1,n-i)):
        chohuku+=1
        k=j+i
        l=i-j
        if s[i]!=s[k] and s[i]!=s[l] and s[l]!=s[k]:
            double+=1
ans=r*g*b-double
print(ans)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n=int(input())
s=input()
r,g,b=0,0,0
for i in range(n):
    if s[i]=="R":
        r+=1
    elif s[i]=="G":
        g+=1
    else:
        b+=1
chohuku=0
double=0
for i in range(1,n-1):
    for j in range(1,min(i+1,n-1-i)):
        chohuku+=1
        k=j+i
        l=i-j
        if s[i]==s[k] or s[i]==s[l] or s[l]==s[k]:
            double+=1
ans=r*g*b-double
print(ans)

Failing test case input:
39
RBBGBRBBBGBRBBBRBGGBBGRBBGRRBBGGBRGBRRR

Expected output:
1806


Actual output:
1610


Fixed submission (verdict: Accepted):
n=int(input())
s=input()
r,g,b=0,0,0
for i in range(n):
    if s[i]=="R":
        r+=1
    elif s[i]=="G":
        g+=1
    else:
        b+=1
chohuku=0
double=0
for i in range(1,n-1):
    for j in range(1,min(i+1,n-i)):
        chohuku+=1
        k=j+i
        l=i-j
        if s[i]!=s[k] and s[i]!=s[l] and s[l]!=s[k]:
            double+=1
ans=r*g*b-double
print(ans)
Problem: p02714
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def main():
    n = int(input())
    s = input()
    
    r = []
    g = []
    b = []
    for ind, c in enumerate(s):
        if c == 'R':
            r.append(ind)
        elif c == 'G':
            g.append(ind)
        else:
            b.append(ind)
    ans = 0
    print(r, g, b)

    for i in r:
        for j in g:
            for k in b:
                o, p, q = sorted((i, j, k))
                if p - o != q - p:
                    ans += 1
    return ans


if __name__ == '__main__':
    print(main())


Failing test case input:
39
BBBGBBBRBGBRBGBRBGGBRRRBBGGRBBGRBRGBRBR

Expected output:
1794


Actual output:
[7, 11, 15, 20, 21, 22, 27, 31, 33, 36, 38] [3, 9, 13, 17, 18, 25, 26, 30, 34] [0, 1, 2, 4, 5, 6, 8, 10, 12, 14, 16, 19, 23, 24, 28, 29, 32, 35, 37]
1794


Fixed submission (verdict: Accepted):
def main():
    n = int(input())
    s = input()
    
    r = set()
    g = set()
    r_add = r.add
    g_add = g.add
    for ind, c in enumerate(s):
        if c == 'R':
            r_add(ind)
        elif c == 'G':
            g_add(ind)
    b = set(range(n)) - r - g

    ans = 0
    for i in r:
        for j in g:
            p, q = min(i, j), max(i, j)
            if (q - p) % 2 == 0 and (p + q) 
                ans -= 1
            if (q + (q - p)) in b:
                ans -= 1
            if (p - (q - p)) in b:
                ans -= 1
            ans += len(b)
    return ans


if __name__ == '__main__':
    print(main())

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
S = input()


R = S.count('R')
G = S.count('G')
B = S.count('B')


ad = R * G * B
ed = 0

for i in range(0, N):
  for j in range(1, N):
    if (i + j) >= N or (i + j * 2) >= N:
      break
    
    if S[i] != S[i+j] and S[j] != S[i+j*2] and S[i+j*2] != S[i+j]:
      ed += 1

print(ad-ed)

Failing test case input:
39
RBBGBBBBBGBRBBBBBGGBBGRBBGRRRBGGBRGRRRR

Expected output:
1817


Actual output:
1792


Fixed submission (verdict: Accepted):
N = int(input())
S = input()


R = S.count('R')
G = S.count('G')
B = S.count('B')


ad = R * G * B
ed = 0

for i in range(0, N-1):
  for j in range(i+1, N):
    
    P = j+(j-i)
    if P < N:
      if S[i] != S[j] and S[j] != S[P] and S[P] != S[i]:
        ed += 1

print(ad-ed)
Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
from sys import stdin
n = int(input())
s = stdin.readline()
r = 0
g = 0 
b = 0
for i in range(n):
    if s[i] == "R":
        r += 1
    elif s[i] == "G":
        g += 1
    else:
        b += 1
count1 = r*g*b
count2 = 0
for i in range(0,n-3):
    for j in range(i+1,n-2):
        if 2*j-i<=n-1:
            if (s[i] != s[j])and(s[i] != s[2*j-i])and(s[j] != s[2*j-i]):
               count2 += 1
print(count1-count2)

Failing test case input:
4
RBGR

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
from sys import stdin
n = int(input())
s = stdin.readline()
r = 0
g = 0 
b = 0
for i in range(n):
    if s[i] == "R":
        r += 1
    elif s[i] == "G":
        g += 1
    else:
        b += 1
count1 = r*g*b
count2 = 0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        if 2*j-i<=n-1:
            if (s[i] != s[j])and(s[i] != s[2*j-i])and(s[j] != s[2*j-i]):
               count2 += 1
print(count1-count2)

Problem: p02714
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
s = input()

R = []
G = []
B = []
for i in range(n):
    if(s[i] == 'R'):
        R.append(i)
    elif(s[i] == 'G'):
        G.append(i)
    else:
        B.append(i)

samu = len(R) * len(G) * len(B)

for i in R:
    for j in G:
        k = int(2 * j - i)
        if(k < n):
            if(s[k] == 'B'):
                samu -= 1
        if(i % 2 == j % 2):
            k = int((i + j) / 2)
            if(s[k] == 'B'):
                samu -= 1

print(samu)

Failing test case input:
39
RBBGBBBBBGBRBBBRBGGBRGRBBGRRBBGGBRGBRRR

Expected output:
1809


Actual output:
1824


Fixed submission (verdict: Accepted):
n = int(input())
s = input()

R = []
G = []
B = []
for i in range(n):
    if(s[i] == 'R'):
        R.append(i)
    elif(s[i] == 'G'):
        G.append(i)
    else:
        B.append(i)

samu = len(R) * len(G) * len(B)

for i in R:
    for j in G:
        k = int(2 * j - i)
        if(0 <= k < n):
            if(s[k] == 'B'):
                samu -= 1
        k = int(2 * i - j)
        if(0 <= k < n):
            if(s[k] == 'B'):
                samu -= 1
        if(i % 2 == j % 2):
            k = int((i + j) / 2)
            if(s[k] == 'B'):
                samu -= 1

print(samu)