Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

N = int(input())
i = 0

for a in range(1, N+1):
    for b in range(1, N+1):
        for c in range(1, N+1):
            i += gcd(a, b, c)
            
print(i)

### FIXED CODE ###

from math import gcd 
N = int(input())
i = 0
 
for a in range(1, N+1):
    for b in range(1, N+1):
        for c in range(1, N+1):
            i += gcd(gcd(a, b), c)
            
print(i)
### BUGGY CODE ###

from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

max_A = max(A)
j = 0
while max_A >> j > 0:
    j += 1
max_j = j

ans = 0
MOD = 10 ** 9 + 7
for j in range(max_j):
    c = [0] * 2
    for i in range(N):
        c[A[i] >> j & 1] += 1
    ans += c[0] * c[1] * (1 << j)
    ans %= MOD
print(ans)


### FIXED CODE ###

from collections import defaultdict

N = int(input())
A = list(map(int, input().split()))

max_A = max(A)
j = 0
while max_A >> j > 0:
    j += 1
max_j = j

ans = 0
MOD = 10 ** 9 + 7
for j in range(max_j):
    c = [0] * 2
    for i in range(N):
        c[A[i] >> j & 1] += 1
    ans += c[0] * c[1] * (1 << j)
    ans %= MOD
print(ans)
### BUGGY CODE ###

n = int(input())
h = list(map(int, input().split()))

ans = 0
for left in range(n - 1):
    right = left + 1
    length = 0
    while right < n and h[right - 1] >= h[right]:
        length += 1
        right += 1
    ans = max(ans, length)
print(ans)


### FIXED CODE ###

n = int(input())
h = list(map(int, input().split()))

dp = [0] * n
dp[0] = 0
ans = 0
for i in range(1, n):
    if h[i - 1] >= h[i]:
        if dp[i - 1] == 0:
            dp[i] = 1
        else:
            dp[i] = dp[i - 1] + 1
        ans = max(dp[i], ans)
print(ans)
### BUGGY CODE ###

a,b = map(int,input().split())

for i in range(a+1,b+1):
    a = a ^ i

print(a)


### FIXED CODE ###

a,b = map(int,input().split())

if a % 2 == 0:
    if (b-a+1)%2 == 0:
        if (b-a+1)%4 == 2:
            print(1)
        else:
            print(0)
    else:
        if (b-a+1)%4 == 1:
            print(0^b)
        else:
            print(1^b)
else:
    if (b-a)%2 == 0:
        if (b-a)%4 == 2:
            print(a^1)
        else:
            print(a^0)
    else:
        if (b-a)%4 == 1:
            print(a^0^b)
        else:
            print(a^1^b)
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
for q in range(Q):
    l, r = map(int, input().split())
    print(S[l-1:r].count("AC"))

### FIXED CODE ###

import sys
def input():
    return sys.stdin.readline().rstrip()

N, Q = map(int, input().split())
S = input()
li = [0]*(N+1)

for i in range(N):
    if S[i:i+2] == 'AC':
        li[i+1] = li[i] + 1
    else:
        li[i+1] = li[i]

for i in range(Q):
    l, r = map(int, input().split())
    print(li[r-1] - li[l-1])
### BUGGY CODE ###

MOD = 10**9 + 7

class Combination:
    def __init__(self, size):
        self.size = size + 2
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % MOD
            self.inv[i] = -self.inv[MOD % i] * (MOD // i) % MOD
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % MOD

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % MOD

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % MOD) % MOD

    def nhr(self, n, r):  # 重複組合せ: x_1 + ... + x_n = r
        return self.ncr(n + r - 1, n - 1)

N = int(input())
comb = Combination(N + 10)

dis = 0
for i in range(1, N + 1):
    dis += comb.ncr(N, i) * 2 * pow(8, N - i, MOD)
    dis %= MOD
ans = pow(10, N, MOD) - dis - pow(8, N, MOD)
print(ans % MOD)


### FIXED CODE ###

MOD = 10**9 + 7

class Combination:
    def __init__(self, size):
        self.size = size + 2
        self.fact = [1, 1] + [0] * size
        self.factInv = [1, 1] + [0] * size
        self.inv = [0, 1] + [0] * size

        for i in range(2, self.size):
            self.fact[i] = self.fact[i - 1] * i % MOD
            self.inv[i] = -self.inv[MOD % i] * (MOD // i) % MOD
            self.factInv[i] = self.factInv[i - 1] * self.inv[i] % MOD

    def npr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * self.factInv[n - r] % MOD

    def ncr(self, n, r):
        if n < r or n < 0 or r < 0:
            return 0
        return self.fact[n] * (self.factInv[r] * self.factInv[n - r] % MOD) % MOD

    def nhr(self, n, r):  # 重複組合せ: x_1 + ... + x_n = r
        return self.ncr(n + r - 1, n - 1)

N = int(input())
comb = Combination(N + 10)

dis = 0
for i in range(1, N + 1):
    dis += comb.ncr(N, i) * 2 * pow(8, N - i, MOD)
    dis %= MOD
ans = pow(10, N, MOD) - dis - pow(8, N, MOD)
print(ans % MOD)
### BUGGY CODE ###

import bisect

N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        ans += bisect.bisect_left(L[j + 1:], L[i] + L[j])

print(ans)


### FIXED CODE ###

import bisect

N = int(input())
L = sorted(list(map(int, input().split())))

ans = 0
for i in range(N):
    for j in range(i + 1, N):
        ans += bisect.bisect_left(L[j + 1:], L[i] + L[j])

print(ans)
### BUGGY CODE ###

s = input()
ans = 0
for i in range(len(s) - 3):
    for j in range(i + 4, len(s) + 1):
        n = int(s[i:j])
        if n % 2019 == 0:
            ans += 1
print(ans)

### FIXED CODE ###

s = input()
l = len(s)
dp = [0 for i in range(2019)]
dp[0] = 1
r = 0
for i in range(1, l + 1):
    r += int(s[-i]) * pow(10, i - 1, 2019)
    r %= 2019
    dp[r] += 1
    
print(sum([(i * (i - 1)) // 2 for i in dp]))
### BUGGY CODE ###

import os
import sys
from collections import defaultdict, Counter, deque
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    
    n,m,k = map(int, input().split())
    n_list = list(map(int, input().split()))
    m_list = list(map(int, input().split()))

    a_list = [0]
    b_list = [0]

    ans = 0
    num = 0

    for i in range(n):
        a_list.append(a_list[i] + n_list[i])

    for i in range(m):
        b_list.append(b_list[i] + m_list[i])


    for i in range(n+1):
        if k < a_list[i]:
            continue
        else:
            for j in range(m+1):
                num = a_list[i] + b_list[j]
                if k < num:
                    break
                else:
                    if ans < i+j:
                        ans = i+j
    print(ans)
            

if __name__ == "__main__":
    main()


### FIXED CODE ###

import os
import sys
from collections import defaultdict, Counter, deque
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush,heapify
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    
    n,m,k = map(int, input().split())
    n_list = list(map(int, input().split()))
    m_list = list(map(int, input().split()))

    a_list = [0]
    b_list = [0]

    ans = 0
    num = 0

    for i in range(n):
        a_list.append(a_list[i] + n_list[i])

    for i in range(m):
        b_list.append(b_list[i] + m_list[i])


    
    for i in range(n+1):
        if k < a_list[i]:
            break
        while(b_list[m] > k - a_list[i]):
            m -= 1
        ans = max(ans, i+m)
    print(ans)
            

if __name__ == "__main__":
    main()
### BUGGY CODE ###

def median(L) :
    L = sorted(L)
    return L[len(L)//2]

N = int(input())
X = list(map(int,input().split()))
for i in range(N) :
    K = X[0:i] + X[(i+1):(N+1)]
    print(median(K))


### FIXED CODE ###

N = int(input())
X = list(map(int,input().split()))
Y = X.copy()
X = sorted(X)
bigger = X[N//2]
smaller = X[N//2-1]

for i in range(N) :
    if Y[i] >= bigger :
        print(smaller)
    else :
        print(bigger)
### BUGGY CODE ###

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n = I()
edge = [[] for _ in range(n)]
for v in range(1,n):
    u = I()-1
    edge[u].append(v)

dp = [inf]*n
def dfs(s):
    if edge[s] == []:
        dp[s] = 0
        return 0
    tmp = []
    for v in edge[s]:
        tmp.append(dfs(v))
    tmp.sort(reverse=True)
    dp[s] = max(list((i+1+j) for i,j in enumerate(tmp)))
    return dp[s]

dfs(0)
print(dp[0])

### FIXED CODE ###

#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))


n = I()
edge = [[] for _ in range(n)]
for v in range(1,n):
    u = I()-1
    edge[u].append(v)

dp = [None]*n
def dfs(s):
    if dp[s] != None:
        return dp[s]
    if edge[s] == []:
        dp[s] = 0
        return 0
    tmp = []
    for v in edge[s]:
        tmp.append(dfs(v))
    tmp.sort(reverse=True)
    m = 0
    for i,j in enumerate(tmp):
        m = max(m,(i+1)+j)
    dp[s] = m
    return m

dfs(0)
print(dp[0])
### BUGGY CODE ###

from bisect import bisect_right as br

n = int(input())
c = list(input())
cFixed = [x for x in c]
cFixed.sort()
ans = 0
for i in range(n):
	if c[i] != cFixed[i]:
		j = br(c,"R", lo = i+1)-1
		while cFixed[j] == c[j]:
			j = br(c, "R", lo = j+1)-1
		c[i] = c[j]
		c[j] = "W"
		ans += 1


print(ans)


### FIXED CODE ###

n = int(input())
c = list(input())
cFixed = [x for x in c]
cFixed.sort()
lastR = -1
for i in range(n):
	if cFixed[i] == "R":
		lastR = i
ans = 0
for i in range(lastR+1):
	if c[i] == "W":
		ans += 1

print(ans)
### BUGGY CODE ###

n = int(input())
s = input()
colors = {'R': 1, 'G' : 2, 'B' : 3}

def dkey(dict, val):
    for e in dict:
        if dict[e] == val:
            return e

sum = [[0] * (n+1) for i in range (3)]
for i in range (3):
    for j in range (n):
        if(s[j] == dkey(colors,i + 1)):
            sum[i][j + 1] = sum[i][j] + 1
        else:
            sum[i][j + 1] = sum[i][j]

ans = 0
for i in range (n-2):
    for j in range (i+1,n-1):
        if s[i] == s[j]:
            continue
        k = 6//(colors[s[i]]*colors[s[j]])
        ans += sum[k-1][n] - sum[k-1][j+1]
        if 2*j-i < n and s[2*j-i] == dkey(colors,k):
            ans -= 1
print(ans)

### FIXED CODE ###

n = int(input())
s = input()
colors = {'R': 1, 'G' : 2, 'B' : 3}

def dkey(dict, val):
    for e in dict:
        if dict[e] == val:
            return e

sum = [[0] * (n+1) for i in range (3)]
for i in range (3):
    for j in range (n):
        if(s[j] == dkey(colors,i + 1)):
            sum[i][j + 1] = sum[i][j] + 1
        else:
            sum[i][j + 1] = sum[i][j]

ans = 0
for i in range (n-2):
    for j in range (i+1,n-1):
        if s[i] == s[j]:
            continue
        k = 6//(colors[s[i]]*colors[s[j]])
        ans += sum[k-1][n] - sum[k-1][j+1]
        if 2*j-i < n and s[2*j-i] == dkey(colors,k):
            ans -= 1
print(ans)
### BUGGY CODE ###

S = input()
T = input()


def solve(S, T):
    for t in set(T):
        if t not in set(S):
            return -1

    S_double = S+S
    len_s = len(S)
    ans = -1
    for t in T:
        ans += S_double[(ans+1) % len_s:].index(t) + 1
    return ans + 1


print(solve(S, T))


### FIXED CODE ###

S = input()
T = input()


def solve(S, T):
    for t in set(T):
        if t not in set(S):
            return -1

    S_double = S+S
    len_s = len(S)
    ans = -1
    for t in T:
        ans += S_double[(ans+1) % len_s:].index(t) + 1
    return ans + 1


print(solve(S, T))
### BUGGY CODE ###

n,k = map(int,input().split())
sl = [0]*n
tree = [[] for i in range(n)]
mod = 10**9+7
q = []
ans = k

for i in range(n-1):
  a,b = map(int,input().split())
  tree[a-1].append(b-1)
  tree[b-1].append(a-1)

def perm(n, k = 1):
  pdt = 1
  if n != int(n) or k != int(k):
    raise ValueError("perm() not defined for float object")
  elif k < 0:
    pdt = 0
  elif n < 0:
    pdt = 0
  else:
    for x in range(n, n-k, -1):
      pdt *= x
  return pdt

if len(tree[0]) > 0:
  q = tree[0]
  ans = k*perm(k-1,len(tree[0]))%mod
  sl[0] = 1
else:
  print(k)
  exit()
  
while q:
  pos = q.pop(0)
  sl[pos] = 1
  lent = len(tree[pos]) - 1
  if lent > 0:
    ans = ans*perm(k-2,lent)%mod
  for i in tree[pos]:
    if sl[i] == 0:
      q.append(i)
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
mod = 10**9+7

def main():
  
  n,k = map(int,input().split())
  sl = [0]*(n+1)
  tree = [[] for i in range(n+1)]
  
  for i in range(n-1):
    a,b = map(int,input().split())
    tree[a] += (b,)
    tree[b] += (a,)

  def dfs(x,depth,k):
    sl[x] = 1
    child = 0
    ans = 1
    for i in tree[x]:
      if sl[i] == 0:
        ans *= dfs(i,depth+1,k)
        child += 1
    if depth == 0:
      for x in range(k-1, k-1-child, -1):
        ans = ans * x % mod   
    else:    
      for x in range(k-2, k-2-child, -1):
        ans = ans * x % mod
    ans %= mod
    return ans

  print(dfs(1,0,k)*k%mod)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
cnt = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if A[i] > A[j]:
            cnt += 1
print(cnt)


### FIXED CODE ###

INF = float("inf")
cnt = 0
def merge(A, left, mid, right):
    global cnt
    L = A[left: mid] + [INF]
    R = A[mid: right] + [INF]
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            A[k] = L[i]
            cnt += j
            i += 1
        else:
            A[k] = R[j]
            j += 1
def mergeSort(A, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        mergeSort(A, left, mid)
        mergeSort(A, mid, right)
        merge(A, left, mid, right)
n = int(input())
S = list(map(int, input().split()))
mergeSort(S, 0, n)
print(cnt)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=map(int,input().split())
    p=list(map(int1,input().split()))
    edge=[[] for _ in range(N)]
    for _ in range(M):
        x,y=map(int1,input().split())
        edge[x].append((0,y))
        edge[y].append((0,x))
    from heapq import heappop,heappush
    def dijkstra(start,n,edges):
        d=[INF]*n
        used=[False]*n
        d[start]=0
        used[start]=True
        edgelist=[]
        for edge in edges[start]:
            heappush(edgelist,edge)
        while edgelist:
            minedge=heappop(edgelist)
            if used[minedge[1]]:
                continue
            v=minedge[1]
            d[v]=minedge[0]
            used[v]=True
            for edge in edges[v]:
                if not used[edge[1]]:
                    heappush(edgelist,(edge[0]+d[v],edge[1]))
        return d
    ans=0
    for i in range(N):
        d=dijkstra(i,N,edge)
        if d[p[i]]==0:
            ans+=1
    print(ans)

if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N,M=map(int,input().split())
    p=list(map(int1,input().split()))
    class UnionFind:
        def __init__(self,n):
            self.par=[i for i in range(n)]
            self.siz=[1]*n
            
        def root(self,x):
            while self.par[x]!=x:
                self.par[x]=self.par[self.par[x]]
                x=self.par[x]
            return x
        
        def unite(self,x,y):
            x=self.root(x)
            y=self.root(y)
            if x==y:
                return False
            if self.siz[x]<self.siz[y]:
                x,y=y,x
            self.siz[x]+=self.siz[y]
            self.par[y]=x
            return True
        
        def is_same(self,x,y):
            return self.root(x)==self.root(y)
        
        def size(self,x):
            return self.siz[self.root(x)]
    
    u=UnionFind(N)
    for _ in range(M):
        x,y=map(int1,input().split())
        u.unite(x,y)
    ans=0
    for i in range(N):
        if u.is_same(i,p[i]):
            ans+=1
    print(ans)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

[x,y]=[int(i) for i in input().split()]
a=0
for i in range(1,10**18+1):
    if i%x==0 and i%y!=0:
        print(i)
        a=a+1
        break
if a==0:
    print(-1)


### FIXED CODE ###

[x,y]=[int(i) for i in input().split()]
a=0
if x%y==0:
    print(-1)
else:
    print(x)
### BUGGY CODE ###

import sys

s = str(sys.stdin.readline())
o = len(s)
while True:
    p1 = s.find("01")
    p2 = s.find("10")
    if p1 == -1 and p2 == -1:
        break
    elif p1 == -1:
        i = p2
    elif p2 == -1:
        i = p1
    else:
        i = p1 if p1 < p2 else p2

    s = s[:i] + s[i + 2:]
    
print(o - len(s))

### FIXED CODE ###

import sys

s = str(sys.stdin.readline())
c0 = s.count('0')
c1 = s.count('1')
r = c0 if c0 < c1 else c1
print(r*2)
### BUGGY CODE ###

import sys
s,t=list(input()),list(input())
n=len(s)
for i in range(n):
  if s.count(s[i])!=t.count(t[i]):
    print('No')
    sys.exit()
print('Yes')

### FIXED CODE ###

import sys
s0,t0=input(),input()
s,t=list(s0),list(t0)
n=len(s)
sn=set(s)
tn=set(t)
if len(sn)!=len(tn) or len(s)!=len(t):
  print('No')
  sys.exit()
for i in range(n):
  if s[i]!=t[i]:
    if s.index(s[i])!=t.index(t[i]):
      print('No')
      sys.exit()
print('Yes')
### BUGGY CODE ###

import numpy as np
N = int(input())
A = list(map(lambda x:(29-len(bin(int(x))[2:]))*'0'+bin(int(x))[2:],input().split()))
B = list(map(lambda x:(29-len(bin(int(x))[2:]))*'0'+bin(int(x))[2:],input().split()))

a_arr = []
b_arr = []
for k in range(29):
    a_arr.append(sorted(list(map(lambda x:int(x[-k-1:],2),A))))
    b_arr.append(list(map(lambda x:int(x[-k-1:],2),B)))

a_arr = np.array(a_arr)
b_arr = np.array(b_arr)

ans_arr = np.zeros(29,int)

for k in range(29):
    ans_arr[k] += np.sum(np.searchsorted(a_arr[k],2**(k+1)-1-b_arr[k],side='right')-np.searchsorted(a_arr[k],2**k-b_arr[k]))
    ans_arr[k] += np.sum(N-np.searchsorted(a_arr[k],3*2**k-b_arr[k]))
    ans_arr[k] %= 2

ans = 0
for k in range(29):
    ans += ans_arr[k]*2**k

print(ans)

### FIXED CODE ###

import numpy as np
N = int(input())
A = np.int32(input().split())
B = np.int32(input().split())

ans_arr = np.zeros(29,int)
for k in range(29):
    a = np.sort(A%(2**(k+1)))
    b = B%(2**(k+1))
    ans_arr[k] += np.sum(np.searchsorted(a,2**(k+1)-1-b,side='right')-np.searchsorted(a,2**k-b))
    ans_arr[k] += np.sum(N-np.searchsorted(a,3*2**k-b))
    ans_arr[k] %= 2

ans = 0
for k in range(29):
    ans += ans_arr[k]*2**k

print(ans)
### BUGGY CODE ###

x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
an = []
ans = []
for i in range(x):
    for j in range(y):
        an.append(lisa[i]+lisb[j])
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:
        ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])


### FIXED CODE ###

x,y,z,k = map(int,input().split())
lisa = list(map(int,input().split()))
lisb = list(map(int,input().split()))
lisc = list(map(int,input().split()))
lisa.sort(reverse=True)
lisb.sort(reverse=True)
lisc.sort(reverse=True)
an = []
ans = []
for num in lisb:
    for nu in lisa:
        an.append(num+nu)
an.sort(reverse=True)
an = an[:min(3001,x*y*z+1)]
for num in lisc:
    for nu in an:
        ans.append(num+nu)
ans.sort(reverse=True)
for i in range(k):
    print(ans[i])
### BUGGY CODE ###

N=int(input())
S=input()
ans=0

def check(i,j,N,x):
  A = S[j+1:].count(x)
  check_index=i+(j-i)*2
  if check_index<=N-1 and S[check_index]==x:
    A-=1
  return A

for i in range(len(S)-2):
  temp=['']*2
  temp[0]=S[i]
  for j in range(i+1,len(S)-1):
    if S[i]!=S[j]:
      temp[1]=S[j]
    else:
      continue
    if 'R' not in temp:
      ans += check(i,j,N,'R')
    elif 'G' not in temp:
      ans += check(i,j,N,'G')
    elif 'B' not in temp:
      ans += check(i,j,N,'B')
    continue

print(ans)

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np
from numba import njit

MOD = 10**9 + 7

N = int(readline())
S = np.array(list(read().rstrip()), np.int8)

R = np.sum(S == ord('R'))
B = np.sum(S == ord('B'))
G = np.sum(S == ord('G'))
 
@njit
def f(S):
    N = len(S)
    ret = 0
    for i in range(N):
        for j in range(i + 1, N):
          k = j + j - i
          if k >= N:
            break
          if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
            ret += 1
    return ret
  
answer = R * B * G - f(S)
print(answer)
### BUGGY CODE ###

cnt = 0
k, s = map(int,input().split())
for i in range(k+1):
    for j in range(k+1):
        for l in range(k+1):
            if i + j + l == s:
                cnt += 1
print(cnt)

### FIXED CODE ###

k, s = map(int,input().split())
cnt = 0
for i in range(k+1):
    for j in range(k+1):
        if 0 <= s - i - j <= k:
            cnt += 1
print(cnt)