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

Rs = 0
Gs = 0
Bs = 0
for i, il in enumerate(S):
    if il == 'R':
        Rs += 1
    if il == 'G':
        Gs += 1
    if il == 'B':
        Bs += 1
num = 0
for i in range(N):
    for step in range(1, N):
        j = i + step
        k = i + 2*step
        if k > N - 1:
            continue
        print(i, j, k)
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            num += 1
print(Rs*Gs*Bs - num)


Failing test case input:
39
RBBGBBBBBGBBBRGRBBGBBGRBGGRRBBGGBRRBRRR

Expected output:
1810


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


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

Rs = 0
Gs = 0
Bs = 0
for il in S:
    if il == 'R':
        Rs += 1
    if il == 'G':
        Gs += 1
    if il == 'B':
        Bs += 1
num = 0
for i in range(N):
    for step in range(1, N):
        j = i + step
        k = i + 2*step
        if k > N - 1:
            break
        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            num += 1
print(Rs*Gs*Bs - num)