Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
in_list = []
for i in range(2):
    in_list.append(input())
N,S = in_list
N = int(N)

filt = []
for i in range(1,N//2+1):
    a = [0,1*i,2*i] + np.array([np.arange(N-2*i)]).T
    filt.extend(a)

res = 0
for i in filt:
    res += (S[i[0]] != S[i[1]] and S[i[1]] != S[i[2]] and S[i[2]] != S[i[0]])
    
rgb = S.count("R") * S.count("G") * S.count("B")
print(rgb - res)


Fixed submission:
import numpy as np
in_list = []
for i in range(2):
    in_list.append(input())
N,S = in_list
N = int(N)

res = 0
for i in range(N-2):
    n = 1
    while True:
        j = i+n
        k = j+n
        if k > N-1: break
        res += (S[i] != S[j] and S[j] != S[k] and S[k] != S[i])
        n += 1
    
    
rgb = S.count("R") * S.count("G") * S.count("B")
print(rgb - res)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
in_list = []
for i in range(2):
    in_list.append(input())
N,S = in_list
N = int(N)

find_ind = []
for i in ['R','G','B']:
    find = (np.array(list(S)) == i)
    find_ind.append(find.argsort()[len(find)-sum(find):])

filt = []
for i in range(1,N//2+1):
    a = [0,1*i,2*i] + np.array([np.arange(N-2*i)]).T
    filt.extend(a)

res = 0
for i in filt:
    res += (S[i[0]] != S[i[1]] and S[i[1]] != S[i[2]] and S[i[2]] != S[i[0]])
    
prod_rgb = len(find_ind[0])*len(find_ind[1])*len(find_ind[2])
print(prod_rgb - res)


Fixed submission:
import numpy as np
in_list = []
for i in range(2):
    in_list.append(input())
N,S = in_list
N = int(N)

res = 0
for i in range(N-2):
    n = 1
    while True:
        j = i+n
        k = j+n
        if k > N-1: break
        res += (S[i] != S[j] and S[j] != S[k] and S[k] != S[i])
        n += 1
    
    
rgb = S.count("R") * S.count("G") * S.count("B")
print(rgb - res)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

in_list = []
for i in range(2):
    in_list.append(input())
N,S = in_list
N = int(N)
res = 0
find_ind = []
for i in ['R','G','B']:
    find = (np.array(list(S)) == i)
    find_ind.append(find.argsort()[::-1][:sum(find)])
    # print(len(find_ind[-1]))

find_ind = np.array(find_ind)
rg_diff = find_ind[0] - find_ind[1].reshape(len(find_ind[1]),1)
rg_diff = np.abs(rg_diff)
# print(rg_diff)
gb_diff = find_ind[1] - find_ind[2].reshape(len(find_ind[2]),1)
gb_diff = np.abs(gb_diff)
gb_diff = gb_diff.T
# print(gb_diff)
br_diff = find_ind[2] - find_ind[0].reshape(len(find_ind[0]),1)
br_diff = np.abs(br_diff)

# print(br_diff)

res = 0
# print(len(gb_diff), len(rg_diff))
for i in range(len(find_ind[1])):
    res += np.sum((rg_diff[i] - gb_diff[i].reshape(len(gb_diff[i]),1)) == 0)
for i in range(len(find_ind[0])):
    res += np.sum((rg_diff[:,i] - br_diff[i].reshape(len(br_diff[i]),1)) == 0)
br_diff = br_diff.T
for i in range(len(find_ind[2])):
    res += np.sum((gb_diff[:,i] - br_diff[i].reshape(len(br_diff[i]),1)) == 0)


print(len(find_ind[0])*len(find_ind[1])*len(find_ind[2])-res)



Fixed submission:
import numpy as np
in_list = []
for i in range(2):
    in_list.append(input())
N,S = in_list
N = int(N)

res = 0
for i in range(N-2):
    n = 1
    while True:
        j = i+n
        k = j+n
        if k > N-1: break
        res += (S[i] != S[j] and S[j] != S[k] and S[k] != S[i])
        n += 1
    
    
rgb = S.count("R") * S.count("G") * S.count("B")
print(rgb - res)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

in_list = []
for i in range(2):
    in_list.append(input())
N,S = in_list
N = int(N)
res = 0
for i in range(N-2):
    str_list = ['R', 'G', 'B']
    str_list.remove(S[i])
    # print("i_str",str_list)
    for j in range(1+i,N-1):
        if S[i] != S[j]:
            a = list(np.copy(str_list))
            a.remove(S[j])
            # print("j_str",a)
            b = (a[0] == np.array(list(S[j+1:])))
            cou_b = sum(b)
            ind_list = b.argsort()[::-1][:cou_b] + j+1

            res += len(ind_list[ind_list-j != j-i])

print(res)



Fixed submission:
import numpy as np
in_list = []
for i in range(2):
    in_list.append(input())
N,S = in_list
N = int(N)

res = 0
for i in range(N-2):
    n = 1
    while True:
        j = i+n
        k = j+n
        if k > N-1: break
        res += (S[i] != S[j] and S[j] != S[k] and S[k] != S[i])
        n += 1
    
    
rgb = S.count("R") * S.count("G") * S.count("B")
print(rgb - res)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

in_list = []
for i in range(2):
    in_list.append(input())
N,S = in_list
N = int(N)
res = 0
for i in range(N-2):
    for j in range(1+i,N-1):
        for k in range(1+j,N):
            if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
                if j-i != k-j:
                    res += 1

print(res)

Fixed submission:
import numpy as np
in_list = []
for i in range(2):
    in_list.append(input())
N,S = in_list
N = int(N)

res = 0
for i in range(N-2):
    n = 1
    while True:
        j = i+n
        k = j+n
        if k > N-1: break
        res += (S[i] != S[j] and S[j] != S[k] and S[k] != S[i])
        n += 1
    
    
rgb = S.count("R") * S.count("G") * S.count("B")
print(rgb - res)