Buggy python submission (verdict: Time Limit Exceeded):
def main():
 
  import sys
  
  def input():
    return(sys.stdin.readline()[:-1])
  
  import collections
 
  N = int(input())
  S = list(input())
 
  CNT_S = collections.Counter(S)
 
  cnt_r = CNT_S['R']
  cnt_b = CNT_S['B']
  cnt_g = CNT_S['G']
 
  total = cnt_r * cnt_g * cnt_b
  subdu = 0
 
 
  for pos in range(N):
      for i in range(1, N):
 
          index_r = pos
          index_m = pos + i
          index_l = pos + 2 * i
 
          if (index_l < N and index_m < N and index_r < N):
              if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                  subdu += 1
 
 
  ans = total - subdu
 
  print(ans)
  
if __name__ == '__main__':
    main()

Fixed submission:
import collections

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

CNT_S = collections.Counter(S)

cnt_r = CNT_S['R']
cnt_b = CNT_S['B']
cnt_g = CNT_S['G']

total = cnt_r * cnt_g * cnt_b
subdu = 0


for pos in range(N):
    for i in range(1, N):
    
        index_r = pos
        index_m = pos + i
        index_l = pos + 2 * i
        
        if (index_l < N and index_m < N and index_r < N):
            if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                subdu += 1


ans = total - subdu

print(ans)

Buggy python submission (verdict: Runtime Error):
def main():
 
  import sys
  input() = sys.stdin.readline()[:-1]
  
  import collections
 
  N = int(input())
  S = list(input())
 
  CNT_S = collections.Counter(S)
 
  cnt_r = CNT_S['R']
  cnt_b = CNT_S['B']
  cnt_g = CNT_S['G']
 
  total = cnt_r * cnt_g * cnt_b
  subdu = 0
 
 
  for pos in range(N):
      for i in range(1, N):
 
          index_r = pos
          index_m = pos + i
          index_l = pos + 2 * i
 
          if (index_l < N and index_m < N and index_r < N):
              if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                  subdu += 1
 
 
  ans = total - subdu
 
  print(ans)
  
if __name__ == '__main__':
    main()
 

Fixed submission:
import collections

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

CNT_S = collections.Counter(S)

cnt_r = CNT_S['R']
cnt_b = CNT_S['B']
cnt_g = CNT_S['G']

total = cnt_r * cnt_g * cnt_b
subdu = 0


for pos in range(N):
    for i in range(1, N):
    
        index_r = pos
        index_m = pos + i
        index_l = pos + 2 * i
        
        if (index_l < N and index_m < N and index_r < N):
            if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                subdu += 1


ans = total - subdu

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():
 
  import sys
  input = sys.stdin.readline
  
  import collections
 
  N = int(input())
  S = list(input())
 
  CNT_S = collections.Counter(S)
 
  cnt_r = CNT_S['R']
  cnt_b = CNT_S['B']
  cnt_g = CNT_S['G']
 
  total = cnt_r * cnt_g * cnt_b
  subdu = 0
 
 
  for pos in range(N):
      for i in range(1, N):
 
          index_r = pos
          index_m = pos + i
          index_l = pos + 2 * i
 
          if (index_l < N and index_m < N and index_r < N):
              if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                  subdu += 1
 
 
  ans = total - subdu
 
  print(ans)
  
if __name__ == '__main__':
    main()
 

Fixed submission:
import collections

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

CNT_S = collections.Counter(S)

cnt_r = CNT_S['R']
cnt_b = CNT_S['B']
cnt_g = CNT_S['G']

total = cnt_r * cnt_g * cnt_b
subdu = 0


for pos in range(N):
    for i in range(1, N):
    
        index_r = pos
        index_m = pos + i
        index_l = pos + 2 * i
        
        if (index_l < N and index_m < N and index_r < N):
            if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                subdu += 1


ans = total - subdu

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def main():

  import collections

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

  CNT_S = collections.Counter(S)

  cnt_r = CNT_S['R']
  cnt_b = CNT_S['B']
  cnt_g = CNT_S['G']

  total = cnt_r * cnt_g * cnt_b
  subdu = 0


  for pos in range(N):
      for i in range(1, N):

          index_r = pos
          index_m = pos + i
          index_l = pos + 2 * i

          if (index_l < N and index_m < N and index_r < N):
              if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                  subdu += 1


  ans = total - subdu

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



Fixed submission:
import collections

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

CNT_S = collections.Counter(S)

cnt_r = CNT_S['R']
cnt_b = CNT_S['B']
cnt_g = CNT_S['G']

total = cnt_r * cnt_g * cnt_b
subdu = 0


for pos in range(N):
    for i in range(1, N):
    
        index_r = pos
        index_m = pos + i
        index_l = pos + 2 * i
        
        if (index_l < N and index_m < N and index_r < N):
            if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                subdu += 1


ans = total - subdu

print(ans)

Buggy python submission (verdict: Runtime Error):
import collections
 
N = int(input())
S = list(input())
 
CNT_S = collections.Counter(S)
 
cnt_r = CNT_S['R']
cnt_b = CNT_S['B']
cnt_g = CNT_S['G']
 
total = cnt_r * cnt_g * cnt_b
subdu = 0
 
 
for pos in range(N):
    for i in range(1, N):
    
        index_r = pos
        index_m = pos + i
        index_l = pos + 2 * i
        
        if (index_l < N and index_m < N and index_r < N):
            if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                subdu += 1
 
 
ans = total - subdu
 
print(ans)

Fixed submission:
import collections

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

CNT_S = collections.Counter(S)

cnt_r = CNT_S['R']
cnt_b = CNT_S['B']
cnt_g = CNT_S['G']

total = cnt_r * cnt_g * cnt_b
subdu = 0


for pos in range(N):
    for i in range(1, N):
    
        index_r = pos
        index_m = pos + i
        index_l = pos + 2 * i
        
        if (index_l < N and index_m < N and index_r < N):
            if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                subdu += 1


ans = total - subdu

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import collections

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

CNT_S = collections.Counter(S)

cnt_r = CNT_S['R']
cnt_b = CNT_S['B']
cnt_g = CNT_S['G']

total = cnt_r * cnt_g * cnt_b
subdu = 0


for pos in range(N):
    for i in range(1, N):
    
        index_r = pos
        index_m = pos + i
        index_l = pos + 2 * i
        
        if (index_l < N and index_m < N and index_r < N):
            if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                subdu += 1


ans = total - subdu

print(ans)

Fixed submission:
import collections

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

CNT_S = collections.Counter(S)

cnt_r = CNT_S['R']
cnt_b = CNT_S['B']
cnt_g = CNT_S['G']

total = cnt_r * cnt_g * cnt_b
subdu = 0


for pos in range(N):
    for i in range(1, N):
    
        index_r = pos
        index_m = pos + i
        index_l = pos + 2 * i
        
        if (index_l < N and index_m < N and index_r < N):
            if (S[index_l] != S[index_m] and S[index_l] != S[index_r] and S[index_m] != S[index_r]):
                subdu += 1


ans = total - subdu

print(ans)