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

import sys,collections as cl,bisect as bs , heapq as hq
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k][0] ==  x:
        return True
    else:
        return False

def search(a,n):
    se = dict()
    for i in range(0,len(a)-n+1):
        kkk = a[i:i+n]
        kkk = "".join(kkk)
        if kkk in se:
            for j in range(len(se[kkk])):
                if se[kkk][j] <= i-n:
                    return True
            else:
                se[kkk].append(i)
        else:
            se[kkk] = [i]
    return False








n = onem()

s = list(input())
l = 0
r = n//2
while True:
    mid = -(-(l+r)//2)
    ans = search(s,mid)
    if l == mid:
        break
    if ans:
        l = mid
    else:
        r = mid-1
print(l)


### FIXED CODE ###

import sys,collections as cl,bisect as bs,heapq as hq
input = sys.stdin.readline
sys.setrecursionlimit(100000)
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

def search(a,n):
    se = dict()
    data = []
    for i in range(0,len(a)-n+1):
        kkk = a[i:i+n]
        kkk = "".join(kkk)
        if In(kkk,data):
            if se[kkk] <= i-n:
                    return True
        else:
            bs.insort(data,kkk)
            se[kkk] = i
    return False
def solver():
    n = onem()

    s = list(input())
    l = 0
    r = n//2
    for i in range(n):
        mid = -(-(l+r)//2)
        ans = search(s,mid)
        if l == mid:
            break
        if ans:
            l = mid
        else:
            r = mid-1
    print(l)



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

n,q=map(int,input().split())
s=input()
a=len(s)
l=[0]*a
for i in range(a-2):
    if s[i]=='A' and s[i+1]=='C':
        l[i],l[i+1]=1,2
for _ in range(q):
    x,y=map(int,input().split())
    z=0
    if l[x-1]==1 and l[x]==2:
        z+=1
    if l[y-2]==1 and l[y-1]==2:
        z+=1
    z+=sum(l[x+1:y-2])//2
    print(z)

### FIXED CODE ###

n,q=map(int,input().split())
s=input()
a=[0]*(n+1)
for i in range(0,n):
    if s[i-1:i+1]=="AC":
        a[i]=a[i-1]+1
    else:
        a[i]=a[i-1]

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

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

if 1 in A:
    num = 1
    c = len(A)
    while(len(A) > num):
        if A[num-1] == num:
            num += 1
        else:
            del A[num-1]
    print(c - len(A))
else:
    print(-1)

### FIXED CODE ###

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

if 1 in A:
    num = 1
    c = 0
    d = len(A)
    for i in range(N):
        if A[i] == num:
            num += 1
            c += 1 
    print(d - c)
else:
    print(-1)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
http://abc063.contest.atcoder.jp/tasks/arc075_b
TLE
"""
import sys
from sys import stdin
from math import ceil
input = stdin.readline


def Cond(monsters, A, B, mid):
    t = [x - (B * mid) for x in monsters]
    t.sort(reverse=True)
    additional_damage = (A - B)

    total_count = 0
    for m in t:
        if m < 1:
            break
        total_count += ceil(m / additional_damage)

    if total_count <= mid:
        return True
    else:
        return False


def main(args):
    # N = 2
    # A = 10
    # B = 4
    # monsters = [20, 20]
    N, A, B = map(int, input().split())
    monsters = [int(input()) for _ in range(N)]

    total_count = 0
    if N == 1:
        total_count = ceil(monsters[0] / A)
    else:
        monsters.sort(reverse=True)
        lb = ceil(monsters[0] / A)
        ub = ceil(monsters[0] / B)
        # lb = 0
        # ub = 1e10

        for _ in range(100):
            mid = (lb + ub) // 2
            if Cond(monsters, A, B, mid):
                ub = mid
            else:
                lb = mid
        total_count = int(ub)

    print(total_count)


if __name__ == '__main__':
    main(sys.argv[1:])

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
http://abc063.contest.atcoder.jp/tasks/arc075_b
TLE
"""
import sys
from sys import stdin
from math import ceil
input = stdin.readline


def Cond(monsters, A, B, mid):
    t = [x - (B * mid) for x in monsters]
    t.sort(reverse=True)
    additional_damage = (A - B)

    total_count = 0
    for m in t:
        if m < 1:
            break
        total_count += ceil(m / additional_damage)

    if total_count <= mid:
        return True
    else:
        return False


def main(args):
    # N = 2
    # A = 10
    # B = 4
    # monsters = [20, 20]
    N, A, B = map(int, input().split())
    monsters = [int(input()) for _ in range(N)]

    total_count = 0
    if N == 1:
        total_count = ceil(monsters[0] / A)
    else:
        monsters.sort(reverse=True)
        lb = ceil(monsters[0] / A)
        ub = ceil(monsters[0] / B)
        # lb = 0
        # ub = 1e10

        for _ in range(30):
            mid = (lb + ub) // 2
            if Cond(monsters, A, B, mid):
                ub = mid
            else:
                lb = mid
        total_count = int(ub)

    print(total_count)


if __name__ == '__main__':
    main(sys.argv[1:])
### BUGGY CODE ###

a = input()
q = int(input())

fflag = 1
for i in range(q):
  qi = input()
  if( qi == "1"):
    fflag *= -1 
  else:
    if( fflag == 1 ):
      if( qi[2] == "2" ):
        a = a + qi[4]
      else:
        a = qi[4] + a
    else:
      if( qi[2] == "2" ):
        a = qi[4] + a
      else:
        a = a + qi[4]      
    
if( fflag == 1 ):
  print( a )
else:
  print( a[::-1] )	

### FIXED CODE ###

a = input()
q = int(input())

fflag = 0
ato = ""
mae = ""
for i in range(q):
  qi = input()
  if( qi == "1"):
    fflag += 1 
  else:
    if( fflag%2 == 0 ):
      if( qi[2] == "2" ):
        ato += qi[4]
      else:
        mae += qi[4]
    else:
      if( qi[2] == "2" ):
        mae += qi[4]
      else:
        ato += qi[4]      
    
a = mae[::-1] + a + ato    
    
if( fflag%2==0 ):
  print( a )
else:
  print( a[::-1] )
### BUGGY CODE ###

N, A, B = map(int, input().split())
for i in range(N):
    if i*(A+B) < N <= (i+1)*(A+B):
        print(min(N-i*B, (i+1)*A))

### FIXED CODE ###

N, A, B = map(int, input().split())
a = N//(A+B)
b = N % (A+B)

if A == 0:
    print(0)
elif b <= A:
    print(a*A+b)
else:
    print(a*A+A)
### BUGGY CODE ###

from math import floor
from collections import defaultdict


def Calc_Divisors(num):
    divisors = []
    for i in range(1, int(sqrt(num)) + 1):
        if num % i == 0:
            divisors.append(i)
            if i != num // i:
                divisors.append(num//i)
    # divisors.sort()
    return divisors


def main():
    N = int(input())
    divlist = defaultdict(int)

    ans = 0
    for i in range(1, N+1):
        ans += i/2 * floor(N/i) * floor(1+N/i)

    print(int(ans))


def test():
    ans = 0
    for i in range(1, 10000000):
        d = Calc_Divisors(i)
        print(len(d))
        ans += len(d) * i
        print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from math import floor
from collections import defaultdict


def Calc_Divisors(num):
    divisors = []
    for i in range(1, int(sqrt(num)) + 1):
        if num % i == 0:
            divisors.append(i)
            if i != num // i:
                divisors.append(num//i)
    # divisors.sort()
    return divisors


def main():
    N = int(input())
    divlist = defaultdict(int)

    ans = 0
    for i in range(1, N+1):
        ans += i/2 * floor(N/i) * floor(1+N/i)

    print(int(ans))


def test():
    ans = 0
    for i in range(1, 10000000):
        d = Calc_Divisors(i)
        print(len(d))
        ans += len(d) * i
        print(ans)


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

N=int(input())
A=list(map(int,input().split()))
L=[x for x in range(1,N+1)]
ans=0
for i in range(N):
  if A[i]!=L[0]:
    ans+=1
  else:
    L.pop(0)

if N==1 and A[0]==1:
  print(0)
elif 1 not in A:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
L=1
ans=0
for i in range(N):
  if A[i]!=L:
    ans+=1
  else:
    L+=1

if N==1 and A[0]==1:
  print(0)
elif 1 not in A:
  print(-1)
else:
  print(ans)
### BUGGY CODE ###

N = int(input())

s = input().split(" ")

judge = False

for i in range(N):

  if s.count(s[i]) > 1:
      judge = True
      break

if judge == True:
  print("NO")
else:
  print("YES")







### FIXED CODE ###

N = int(input())

s = input().split(" ")

b = len(s)

s = set(s)

a = len(s)



if a == b:
  print("YES")
else:
  print("NO")
### BUGGY CODE ###

n_ = 2 * 10**6 + 5
mod = 10**9 + 7
fun = [1] * (n_ + 1)
for i in range(1, n_ + 1):
    fun[i] = fun[i - 1] * i % mod
rev = [1] * (n_ + 1)
rev[n_] = pow(fun[n_], mod - 2, mod)
for i in range(n_ - 1, 0, -1):
    rev[i] = rev[i + 1] * (i + 1) % mod


def nCr(n, r):
    if r > n:
        return 0
    return fun[n] * rev[r] % mod * rev[n - r] % mod


def modinv(x, mod):
    a, b = x, mod
    u, v = 1, 0
    while b:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    return u % mod


inv26 = modinv(26, mod)

K = int(input())
S = input()
M = len(S)

ans = 0
po = 1
poo = pow(26, K, mod)
for i in range(K+1):
    ans = (ans + po * poo % mod * nCr(i+M-1, i)) % mod
    po = po * 25 % mod
    poo = poo * inv26 % mod
print(ans)


### FIXED CODE ###

n_ = 2 * 10**6 + 5
mod = 10**9 + 7
fun = [1] * (n_ + 1)
for i in range(1, n_ + 1):
    fun[i] = fun[i - 1] * i % mod
rev = [1] * (n_ + 1)
rev[n_] = pow(fun[n_], mod - 2, mod)
for i in range(n_ - 1, 0, -1):
    rev[i] = rev[i + 1] * (i + 1) % mod


def nCr(n, r):
    if r > n:
        return 0
    return fun[n] * rev[r] % mod * rev[n - r] % mod


def modinv(x, mod):
    a, b = x, mod
    u, v = 1, 0
    while b:
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    return u % mod


inv26 = modinv(26, mod)

K = int(input())
S = input()
M = len(S)

ans = 0
po = 1
poo = pow(26, K, mod)
for i in range(K+1):
    ans = (ans + po * poo % mod * nCr(i+M-1, i)) % mod
    po = po * 25 % mod
    poo = poo * inv26 % mod
print(ans)
### BUGGY CODE ###

N,K = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
if a[0] >= K:
    print(0)
    exit()

a = [a[i] for i in range(N) if a[i]<K]
a.reverse()
N = len(a)
ans = N
dp = [False]*K
dp[0] = True
Smax = 0
for i in range(N):
    if Smax + a[i] >= K:
        ans = N-i-1
    updated = False
    for j in range(min(Smax,K-a[i]-1),-1,-1):
        if dp[j]:
            dp[j+a[i]]=True
            if not updated:
                Smax = max(Smax,j+a[i])
                updated = True

print(ans)

### FIXED CODE ###

N,K = map(int,input().split())
a = list(map(int,input().split()))

def f(N,K,a):
    a.sort()
    if a[0] >= K:
        print(0)
        exit()

    a = [a[i] for i in range(N) if a[i]<K]
    N = len(a)
    ans = N
    dp = [False]*K
    dp[0] = True
    Smax = 0
    for i,a_ in reversed(list(enumerate(a))):
        if Smax + a_ >= K:
            ans = i
        updated = True
        for j in range(min(Smax,K-a_-1),-1,-1):
            if dp[j]:
                dp[j+a_]=True
                if updated:
                    Smax = max(Smax,j+a_)
                    updated = False
    return ans

print(f(N,K,a))
### BUGGY CODE ###

H,N = map(int, input().split())
A = []
B = []
for _ in range(N):
    a,b = map(int, input().split())
    A.append(a)
    B.append(b)

dp = [10**9]*(H+1)
dp[0] = 0
for i in range(N):
    for j in range(H+1):
        if j < A[i]:
            dp[j] = min(dp[j], B[i])
        else:
            dp[j] = min(dp[j], B[i]+dp[j-A[i]])

print(dp[H])

### FIXED CODE ###

from operator import itemgetter
H,N = map(int, input().split())
L = [[int(l) for l in input().split()] for _ in range(N)]

L.sort(key=itemgetter(1))
inf = 10**9
dp = [[inf]*(H+1) for _ in range(N+1)]
dp[0][0] = 0

for i in range(N):
    for j in range(H+1):
        if j < L[i][0]:
            dp[i+1][j] = min(dp[i][j], L[i][1])
        else:
            dp[i+1][j] = min(dp[i][j], dp[i+1][j-L[i][0]]+L[i][1])
    for j in range(H, -1, -1):
        if dp[i+1][j] < inf:
            num = dp[i+1][j] + dp[i+1][H-j]
            break
    for j in range(H, -1, -1):
        if dp[i+1][j] > num:
            dp[i+1][j] = num
        else:
            num = dp[i+1][j]

print(dp[N][H])
### BUGGY CODE ###

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


ans=0
for i in range(n-1):
    for j in range(i+1,n):
        ans = ( ans + (a[i]*a[j]) )%(10**9+7)
print(ans)

### FIXED CODE ###

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

a2=[a[n-1]]
for i in range(n-1,0,-1):
    a2.append(a2[-1]+a[i-1])
ans=0
for i in range(n-1):
    ans = ( ans + (a[i]*a2[-i-2]) )%(10**9+7)
print(ans)
### BUGGY CODE ###

import itertools

def cf(x1,x2):
    cf=[]
    for i in range(1,min(x1,x2)+1):
        if x1 % i == 0 and x2 % i == 0:
            cf.append(i)
    return cf

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def main():
    A, B = map(int, input().split())

    C = cf(A,B)

    cnt = 1
    for c in C:
        if is_prime(c):
            cnt += 1

    print(cnt)

main()

### FIXED CODE ###

import itertools

def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return ass

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True

def main():
    A, B = map(int, input().split())

    div_A = divisor(A)
    div_B = divisor(B)
    C = list(set(div_A) & set(div_B))
    cnt = 1
    for c in C:
        if is_prime(c):
            cnt += 1

    print(cnt)

main()
### BUGGY CODE ###

import heapq

N = int(input().strip())
A = list(map(int, input().strip().split()))
A.insert(0,0)
#print(A)
INF = 1 << 32
adj = [[INF for i in range(N+1)] for j in range(N+1)]
for i in range(N+1):
    for j in range(i+1, N+1):
        if A[i] + 1 == A[j]:
            adj[i][j] = 1

#print(adj)

dist = [INF] * (N + 1)
dist[0] = 0
hq = []
heapq.heappush(hq, (0, 0))
while len(hq) > 0:
    d, from_node = heapq.heappop(hq)
    if dist[from_node] < d:
        continue
    for to_node in range(N + 1):
        weight = adj[from_node][to_node]
        # 辺がないところはスキップ
        if weight == INF:
            continue
        weight = - weight
        if dist[to_node] == INF or dist[from_node] + weight < dist[to_node]:
            dist[to_node] = dist[from_node] + weight
            heapq.heappush(hq, (dist[to_node], to_node))
#print(dist)
ans = min(dist)
if ans >= 0:
    print(-1)
else:
    print(N+ans)

### FIXED CODE ###

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

cnt = 0
for num in A:
    if num == cnt + 1:
        cnt+=1
if cnt == 0:
    print(-1)
else:
    print(N - cnt)
### BUGGY CODE ###

if __name__ == "__main__":
    mod = 10 ** 9 + 7
    n, m = map(int, input().split())
    a = list()
    for i in range(m):
        a.append(int(input()))

    dp = [0] * (n + 1)

    if 1 not in a:
        dp[1] = 1

    if n > 1:
        if 2 not in a:
            dp[2] = 1 + dp[1]

        for i in range(3, n + 1):
            if i not in a:
                dp[i] = dp[i-2] + dp[i-1]

    print(dp[n] % mod)


### FIXED CODE ###

if __name__ == "__main__":
    mod = 10 ** 9 + 7
    n, m = map(int, input().split())
    a = list()
    for i in range(m):
        a.append(int(input()))

    dp = [0] * (n + 1)

    for aa in a:
        dp[aa] = -1

    if dp[1] != -1:
        dp[1] = 1
    else:
        dp[1] = 0

    if n > 1:
        if dp[2] != -1:
            dp[2] = 1 + dp[1]
        else:
            dp[2] = 0

        for i in range(3, n+1):
            if dp[i] != -1:
                dp[i] = (dp[i-2] + dp[i-1]) % mod
            else:
                dp[i] = 0

    print(dp[n])
### BUGGY CODE ###

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

minv = float('inf')
for i in range(-max(a),max(a)+1):
  cnt = 0
  for j in range(N):
    cnt += abs(a[j] - (i + j))
  if minv > cnt:
    minv = cnt
    
print(minv)

### FIXED CODE ###

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

for i in range(N):
  a[i] = a[i] - (i+1)

a.sort()
med = [a[N//2-1],a[N//2]]
mina = 0
for i in range(N):
  mina += abs(a[i] - med[0])

minb = 0
for i in range(N):
  minb += abs(a[i] - med[1])

print(min(mina,minb))
### 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()))

def solve():
    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)->int:
        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])

if __name__=='__main__':
    solve()



### 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 ###

s=input()
l=len(s)
mod = pow(10,9)+7

dp = [[0 for i in range(13)] for j in range(l+1)]
dp[0][0] = 1

for i in range(1,l+1):
	num = s[-i]
	keta = pow(10,i-1)
	if num == '?':
		for j in range(10):
			for k in range(13):
				dp[i][(j * keta + k) % 13] += dp[i-1][k]
	else:
		for k in range(13):
			dp[i][(int(num) * keta + k) % 13] += dp[i-1][k]
print(dp[l][5] % mod)

### FIXED CODE ###

INF = 10 ** 9 + 7

S = input()
# dp[i][j]はうしろからi桁を13で割った余りがjであるものの個数
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
mul = 1

for i in range(len(S)):
    x = S[-(i + 1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= INF
    else:
        k = int(x)
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= INF
    mul = mul * 10 % 13  # 計算量削減のためここで13で割っている

print(dp[len(S)][5])
### BUGGY CODE ###

### INPUT
N = int(input())
A = list(map(int,input().split()))
cont = 0
CN = [0]
b = N-1
### MAIN
for i in range(b):
    s = i
    while A[s]>=A[s+1] and s+1!=b:
        cont = cont + 1
        s = 1 + s
    if  (A[s]>=A[s+1]) and (s+1==b):
        cont =cont + 1
    if  cont != 0:
        CN.extend([cont])
        cont = 0
### MAX

print(max(CN))


### FIXED CODE ###

### INPUT
N = int(input())
A = list(map(int,input().split()))
cont = 0
b = N-1
MAX = 0
### MAIN
for i in range(b):
    if A[i]>=A[i+1] :
        cont = cont + 1
    else:
        cont = 0

    if cont > MAX:
        MAX = cont
### OUT
print(MAX)
### BUGGY CODE ###


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

Rn=S.count('R')
Gn=S.count('G')
Bn=S.count('B')

ans=0

for k in range(N//2-2+1 if N&1==0 else N//2-1+1):#k個飛ばし
    i=0
    while i+2*(k+1)<=N-1:
        ls=[S[i],S[i+k+1],S[i+2*(k+1)]]
        if "R" in ls and "G" in ls and "B" in ls:
            ans+=1
        i+=1

print(Rn*Gn*Bn-ans)

### FIXED CODE ###

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

R_num=S.count('R')
G_num=S.count('G')
B_num=S.count('B')

ans=0
for k in range(N//2-2+1 if N&1==0 else N//2-1+1):
    flag=0
    for i in range(N-k-2):

        if i+2*(k+1)<=N-1:
            ls=[S[i],S[i+k+1],S[i+2*(k+1)]]
    
            if "R" in ls and "G" in ls and "B" in ls:
                ans+=1


print(R_num*G_num*B_num-ans)
### BUGGY CODE ###

def prime_factors(n):       # 戻り値はiterable type
    i = 2
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            yield i             # whileループを進めるごとにイテレータに値を貯め続ける
    if n > 1:
        yield n

def min2(x,y):
    return x if x < y else y

from itertools import combinations

N = int(input())
P = list(prime_factors(N))
L = len(P) + 1
res =float("inf")

for k in range(L//2, 0, -1):
    for a in combinations(prime_factors(N), k):
        q = 1
        for p in a:
            q *= p
        res = min2((q - 1) + (N // q - 1), res)

print(res)

### FIXED CODE ###

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

def min2(x,y):
    return x if x < y else y

N = int(input())
P = make_divisors(N)
L = len(P) + 1
res =float("inf")

for p in P:
    res = min2((p - 1) + (N // p - 1), res)

print(res)
### BUGGY CODE ###

import math
n, k = map(int, input().split())
"""
def cmb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

mod = 10**9+7
"""
def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r]

mod = 10**9+7 #出力の制限
N = 2000
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) )
    g2.append( (g2[-1] * inverse[-1]) )

for i in range(1, k + 1):
    print(cmb(n - k + 1, i) * cmb(k - 1, i - 1) % mod)

### FIXED CODE ###

import math
n, k = map(int, input().split())
"""
def cmb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

mod = 10**9+7
"""
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2000
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for i in range(1, k + 1):
    print((cmb(n - k + 1, i, mod) * cmb(k - 1, i - 1, mod)) % mod)
    #print(cmb(n - k + 1, i))
    #print(cmb(k - 1, i - 1))