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

[K,S] = list(map(int,input().split()))

count=0
for X in range(K+1):
    for Y in range(K+1):
        for Z in range(K+1):
            if X+Y+Z==S:
                count+=1
print(count)

### FIXED CODE ###

[K,S] = list(map(int,input().split()))

count=0
for X in range(K+1):
    for Y in range(K+1):
        Z = S - X - Y
        if Z in range(K+1):
            count+=1

print(count)
### BUGGY CODE ###

n=int(input()) 
a=list(map(int,input().split())); 
ans=1; 
for i in a:
	ans=ans*i
x=10**18 
if ans>x:
	print(-1) 
else:
	print(ans)

### FIXED CODE ###

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

x=10**18 
flag=0;
for i in a:
	if i==0:
		flag=1
		break

for i in a:
	ans=ans*i
	if ans>x:
		break
if flag==1:
	ans=0
if ans>x :
	print(-1) 
else:
	print(ans)
### BUGGY CODE ###

from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_list_of_int():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


# inputs
A, B, Q = 0, 0, 0
S = []
T = []
X = []


def set_inputs():
    global A, B, Q, S, T, X
    A, B, Q = get_list_of_int()
    for _ in range(A):
        S.append(get_int())
    for _ in range(B):
        T.append(get_int())
    for _ in range(Q):
        X.append(get_int())


def main():
    set_inputs()

    for i in range(Q):
        ns = abs(max([S[j] - X[i] for j in range(A) if S[j] - X[i] <= 0] + [-inf]))
        ps = abs(min([S[j] - X[i] for j in range(A) if S[j] - X[i] >= 0] + [inf]))
        nt = abs(max([T[j] - X[i] for j in range(B) if T[j] - X[i] <= 0] + [-inf]))
        pt = abs(min([T[j] - X[i] for j in range(B) if T[j] - X[i] >= 0] + [inf]))
        print(min(max(ns, nt), max(ps, pt), ns * 2 + pt, ns + pt * 2, nt * 2 + ps, nt + ps * 2))


if __name__ == '__main__':
    main()


### FIXED CODE ###

from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from functools import lru_cache, reduce
from math import ceil, floor

import heapq
import itertools
import operator


inf = float('inf')


def get_int():
    return int(input())


def get_str():
    return input().strip()


def get_list_of_int():
    return [int(i) for i in input().split()]


def get_char_list():
    return list(input().strip())


# inputs
A, B, Q = 0, 0, 0
S = []
T = []
X = []


def set_inputs():
    global A, B, Q, S, T, X
    A, B, Q = get_list_of_int()
    for _ in range(A):
        S.append(get_int())
    for _ in range(B):
        T.append(get_int())
    for _ in range(Q):
        X.append(get_int())


def main():
    set_inputs()

    for i in range(Q):
        nsi = bisect_left(S, X[i])
        if nsi == 0:
            ns = inf
        else:
            ns = X[i] - S[nsi-1]
        psi = bisect_left(S, X[i])
        if psi == A:
            ps = inf
        else:
            ps = S[nsi] - X[i]
        nti = bisect_left(T, X[i])
        if nti == 0:
            nt = inf
        else:
            nt = X[i] - T[nti-1]
        pti = bisect_left(T, X[i])
        if pti == B:
            pt = inf
        else:
            pt = T[nti] - X[i]
        print(min(max(ns, nt), max(ps, pt), ns * 2 + pt, ns + pt * 2, nt * 2 + ps, nt + ps * 2))


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

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

ans = 0
for i in range(n):
    if min(l[0:i + 1]) == l[i]:
        ans += 1
print(ans)


### FIXED CODE ###

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

ans = 0
min_val = l[0]
for i in range(n):
    if min_val >= l[i]:
        ans += 1
        min_val = l[i]
print(ans)
### BUGGY CODE ###

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

ans=0
for i in range(n):
    a = a_input[i]
    for idx,j in enumerate(range(i+1,n),1):
        if idx-a==a_input[j]:
            ans+=1
print(ans)

### FIXED CODE ###

n = int(input())
a_inputs = [int(i) for i in input().split()]

dic_l={}
dic_r={}
for i in range(n):
    a = a_inputs[i]+(i+1)
    b = (i+1)-a_inputs[i]
    dic_l[a]=dic_l.get(a,0)+1
    dic_r[b]=dic_r.get(b,0)+1

ans=0
for key in dic_l.keys():
    ans+=dic_l[key]*dic_r.get(key,0)
    
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

from bisect import bisect_left, bisect_right

N = int(input().rstrip())
S = input()
Q = int(input())
Ks = list(map(int, input().split()))

for K in Ks:
    # [D, M, DM, DMC]
    dp = [[0]*4 for _ in range(N+1)]
    for i in range(N):
        if i-K >= 0:
            sk = S[i-K]
            if sk == 'D':
                dp[i][0] -= 1
                dp[i][2] -= dp[i][1]
            elif sk == "M":
                dp[i][1] -= 1
        s = S[i]
        if s == "D":
            dp[i+1][0] = dp[i][0] + 1
            dp[i+1][1] = dp[i][1]
            dp[i+1][2] = dp[i][2]
            dp[i+1][3] = dp[i][3]
        elif s == 'M':
            dp[i+1][0] = dp[i][0]
            dp[i+1][1] = dp[i][1] + 1
            dp[i+1][2] = dp[i][2] + dp[i+1][0]
            dp[i+1][3] = dp[i][3]
        elif s == 'C':
            dp[i+1][0] = dp[i][0]
            dp[i+1][1] = dp[i][1]
            dp[i+1][2] = dp[i][2]
            dp[i+1][3] = dp[i][3] + dp[i][2]
        else:
            dp[i+1][0] = dp[i][0]
            dp[i+1][1] = dp[i][1]
            dp[i+1][2] = dp[i][2]
            dp[i+1][3] = dp[i][3]
    
    print(dp[N][3])

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N = int(input().rstrip())
    S = input()
    Q = int(input())
    Ks = list(map(int, input().split()))

    for K in Ks:
        # [D, M, DM, DMC]
        dp = [0]*4
        for i in range(N):
            if i-K >= 0:
                sk = S[i-K]
                if sk == 'D':
                    dp[0] -= 1
                    dp[2] -= dp[1]
                elif sk == "M":
                    dp[1] -= 1
            s = S[i]
            if s == "D":
                dp[0] += 1
            elif s == 'M':
                dp[1] += 1
                dp[2] += dp[0]
            elif s == 'C':
                dp[3] += dp[2]
        
        print(dp[3])
    

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

n=int(input())
a=list(map(int,input().split()))
result=1
if a in [0]:
    print(0)
else:
    for i in a:
        result*=i
    if result>10**18:
        print(-1)
    else:
        print(result)


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
result=1
if 0 in a:
    print(0)
else:
    for i in a:
        result*=i
        if result>10**18:
            print(-1)
            break
    if result<=10**18:
        print(result)
### BUGGY CODE ###

import copy

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

def gcd(a, b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)
def gcd_array(a):#aは配列
  ans = a[0]
  for i in range(len(a)-1):
    ans = gcd(ans, a[i+1])
  return ans

ans = []
lst_t = []
for i in range(n):
  lst_t = copy.deepcopy(lst)
  del lst_t[i]
  x = gcd_array(lst_t)
  ans.append(x)
  
print(max(ans))

### FIXED CODE ###

import fractions

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

ans = 0
left = [0]
right = [0] * (n+1)

for i in range(n):
  left.append(fractions.gcd(left[-1],lst[i]))
  right[n-1-i] = fractions.gcd(right[n-i],lst[n-1-i])

for i in range(n):
  x = fractions.gcd(left[i], right[i+1])
  if ans < x:
    ans = x
print(ans)
### BUGGY CODE ###

#!/usr/bin/env python3
import itertools
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = [1]
if k > len(list(itertools.permutations(a))):
    for i in range(k % n):
        ans.append(a[ans[i] - 1])
    print(a[-1])
else:
    for i in range(k):
        ans.append(a[ans[i] - 1])
    print(a[-2])    


### FIXED CODE ###

#!/usr/bin/env python3
n, k = map(int, input().split())
a = list(map(int, input().split()))
ans = [1]
c = 1
for i in range(n):
    ans.append(a[ans[i] - 1])
b = ans.index(ans[n])
if k < b:
    for l in range(k):
        c = a[c - 1]
else:
    for l in range((k-b)%(n-b)+b):
        c = a[c - 1]
print(c)
### BUGGY CODE ###

N, Q = map(int, input().split())
S = input()
l = []
for i in range(Q):
    l.append(list(map(int, input().split())))

ans = []
for li in l:
    ps = S[li[0]-1:li[1]]
    num = 0
    for e1, e2 in zip(ps, ps[1:]):
        if e1 == 'A' and e2 == 'C': 
            num += 1
    print(num)

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()

pos = [0] * N
i = 0
while i < N-1:
    if S[i] == 'A':
        if S[i+1] == 'C':
            pos[i+1] = 1
    i += 1

nums = [0] * (N+1)
for i in range(1, N+1):
    nums[i] += nums[i-1] + pos[i-1]

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

N = int(input())


for i in range(1,N+1):
  count = 0
  if i < 6:
    print('0')
  elif i == 6:
    print('1')
  else:
    for j in range(1,i):
      for k in range(1,i):
        for l in range(1,i):
          if (j**2+k**2+l**2+j*k+k*l+l*j)==i:
            count+=1
    print(count)

### FIXED CODE ###

N = int(input())
l = [0]*N

for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      if (x**2+y**2+z**2+x*y+y*z+z*x)<=N:
        l[x**2+y**2+z**2+x*y+y*z+z*x-1]+=1

for i in l:
  print(i)
### BUGGY CODE ###

a, b, c, d = map(int, input().split())
z = []

for x in range(a, b + 1):
  for y in range(c, d + 1):
    z.append(x * y)
print(max(z))

### FIXED CODE ###

a, b, c, d = map(int, input().split())
print(max(a * c, a * d, b * c, b * d))
### BUGGY CODE ###

def muridesu():
    N,K=[int(_) for _ in input().split()]
    aA=sorted(int(_) for _ in input().split())
    dsA = set(aA)
    def f(i,aA):
        return sum(i^a for a in aA)
    def binlen(i):
        return len(bin(i)) - 2
    if 2**binlen(aA[-1]) <= K:
        print(max(f(k,aA) for k in (set(range(aA[-1],K+1)) | {0})))
    else:
        print(max(f(k,aA) for k in (set(range(1,K+1)) - dsA  | {0})))

muridesu()


### FIXED CODE ###

#場合分けがつらい
def 解():
    N,K=[int(_) for _ in input().split()]
    aD =[0]*40
    aA=[int(_) for _ in input().split()]
    iL = 0
    for i in range(40):
        m = 2**i
        aD[i]=sum((_ & m) for _ in aA)
        if aD[i]:
            iL = i
    iLK = len(bin(K))-3
    iML = max(iL,iLK)
    dp = [[0]*2 for _ in range(2)]
    #[x][0] Kに沿う
    #[x][0] Kに沿わない最大
    for i in range(iML,-1,-1):
        ib = i%2 #桁%2 dp
        inb = 0 if ib else 1 #次のdp
        i0 = aD[i] #反転しない
        i1 = (2**i)*N-i0 #反転する
        iM = max(i0,i1) #選べるとき
        bL = i < iLK #Kより長い
        if (K>>i)&1:
            dp[inb][1] = dp[ib][1] + i1
            dp[inb][0] = max(dp[ib][1] + i0 ,dp[ib][0]+(iM if bL else i0))
        else:
            dp[inb][1] = dp[ib][1] + i0
            dp[inb][0] = dp[ib][0] + (iM if bL else i0)
    print(max(dp[inb]))
解()
### BUGGY CODE ###

n,b,r=map(int,input().split())

flag = True
count = 0
counts = 0
while flag == True:
  for i in range(b):
    count += 1
    counts += 1
    if counts == n:
      flag = False
      break
  for i in range(r):
    counts += 1
    if counts == n:
      flag = False
      break

print(count)

### FIXED CODE ###

n,b,r=map(int,input().split())


count = n // (b+r)
counts = n % (b+r)

countss=b*count
if counts<= b:
  coun=counts
else:
  coun=b

print(countss+coun)
### BUGGY CODE ###

import copy

def gcd(x, y):
  if y == 0:
    return x
  else:
    return gcd(y, x % y)

def cal(array):
  while(len(array) > 1):
    a = int(array.pop(0))
    b = int(array.pop(0))
    array.append(gcd(a, b))
  return array[0]

n = int(input())
a = input().split()

answer_list = []

for i in range(int(n)):
  copy_a = copy.copy(a)
  copy_pop_a = copy_a.pop(i)
  answer_list.insert(0, cal(copy_a))

answer = max(answer_list)

print(answer)


### FIXED CODE ###

import copy
import heapq
import fractions

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

gcd_l = [0]
gcd_r = [0]

for i in range(N):
  gcd_l.append(fractions.gcd(gcd_l[i], A[i]))
  gcd_r.append(fractions.gcd(gcd_r[i], A[-(i+1)]))

gcd_r = gcd_r[::-1]
ans = []

for i in range(N):
  ans.append(fractions.gcd(gcd_l[i], gcd_r[i+1]))

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

N = int(input())
A = list(map(int,input().split(" ")))
Q = int(input())
B = [list(map(int,input().split(" "))) for i in range(0,Q)]

for i in range(0,Q):
    index = [j for j, x in enumerate(A) if x == B[i][0]]
    for j in index:
        A[j] = B[i][1]
    print(sum(A))
#print("\n".join(list(map(str,A.tolist()))))

### FIXED CODE ###

import collections
N = int(input())
A = list(map(int,input().split(" ")))
Q = int(input())
B = [list(map(int,input().split(" "))) for i in range(0,Q)]
ans = sum(A)
num = collections.Counter(A)
for i in range(0,Q):
    before, after = B[i][0], B[i][1]
    ans += num[before] * (after - before)
    num[after] += num[before]
    num[before] = 0
    print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)

def addc(p,b):
  for i in e[p]:
    if(i == b):
      continue
    c[i] += c[p]
    addc(i,p)

n,q = map(int,input().split())

e = [ [] for i in range(n + 1)]
c = [0 for i in range(n + 1)]

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

for i in range(q):
  p,x = map(int,input().split())
  c[p] += x

addc(1,-1)

c.pop(0)

print(*c)

### FIXED CODE ###

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

def addc(p,b):
  for i in e[p]:
    if(i == b):
      continue
    c[i] += c[p]
    addc(i,p)

n,q = map(int,input().split())

e = [ [] for i in range(n + 1)]
c = [0]*(n+1)

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

for i in range(q):
  p,x = map(int,input().split())
  c[p] += x

addc(1,-1)

print(*c[1:])
### BUGGY CODE ###

N,A = map(int,input().split())
X = [0]+list(map(int,input().split()))

dp = [[[0 for _ in range(2500+1)] for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1

for i in range(1,N+1):
    for j in range(0,i+1):
        for k in range(2500+1):
            if j==0 and k==0:
                dp[i][j][k] = 1
            elif k < X[i]:
                dp[i][j][k] = dp[i-1][j][k]
            elif j > 0 and k >= X[i]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i]]

if max(X) < A:
    print(0)
else:
    Ans = 0
    for i in range(1,N+1):
        Ans += dp[N][i][A*i]
    print(Ans)

### FIXED CODE ###

N,A = map(int,input().split())
X = [0]+list(map(int,input().split()))

dp = [[[0 for _ in range(2500+1)] for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1

for i in range(1,N+1):
    for j in range(0,i+1):
        for k in range(2500+1):
            if j==0 and k==0:
                dp[i][j][k] = 1
            elif k < X[i]:
                dp[i][j][k] = dp[i-1][j][k]
            elif j > 0 and k >= X[i]:
                dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-X[i]]

if max(X) < A:
    print(0)
else:
    Ans = 0
    for i in range(1,N+1):
        Ans += dp[N][i][A*i]
    print(Ans)
### BUGGY CODE ###

import math

N = 1000001
 
spf = [*range(N)]
i = 2
while i * i < N:
  if spf[i] == i:
    for j in range(i * i, N, i):
      if spf[j] == j:
        spf[j] = i
  i += 1
  
r = 'pairwise'

input()
d = None
u = set()
for x in map(int, input().split()):
  d = math.gcd(d or x, x);
  s = set()
  while x > 1:
    p = spf[x]
    if p in u:
      r = 'setwise'
    s.add(p)
    x //= p
  u |= s
print('not' if d > 1 else r, 'coprime')


### FIXED CODE ###

N = 1000001
 
spf = [*range(N)]
i = 2
while i * i < N:
  if spf[i] == i:
    for j in range(i * i, N, i):
      if spf[j] == j:
        spf[j] = i
  i += 1
  
r = 'pairwise'
n = int(input())
a = [int(x) for x in input().split() if x > '1']
if len(a) > 1:
  u = set()
  i = None
  for x in a:
    s = set()
    while x > 1:
      p = spf[x]
      if p in u:
        r = 'setwise'
      s.add(p)
      x //= p
    u |= s
    if len(a) == n:
      if i is None: i = s
      else: i &= s
  if i:
    r = 'not'
print(r, 'coprime')
### BUGGY CODE ###

n = int(input())
p = list(map(int,input().split()))
pp = list()
pp.append(p[0])
cnt=1
for i in range(1,n):
    min_pp = min(pp)
    if p[i] <= min_pp:
        cnt +=1
    pp.append(p[i])
print(cnt)

### FIXED CODE ###

n = int(input())
p = list(map(int,input().split()))
min_p = p[0]
cnt=1
for i in range(1,n):
    if p[i] <= min_p:
        min_p = p[i]
        cnt +=1
print(cnt)
### BUGGY CODE ###

#http://compro.tsutajiro.com/archive/180220_probability_dp.pdf
import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split( )))
cnt =[0,0,0]
for i in range(n):
    cnt[3-a[i]] += 1
dp = [[[-1 for _ in range(n+2)] for __ in range(n+2)] for ___ in range(n+2)]
"""

for i in range(n,-1,-1):
    for j in range(n,i-1,-1):
        for k in range(n,j-1,-1):
            dp[k][j][i] = (dp[k-1][j+1][i] + 1) * k/n +(dp[k][j-1][i+1] + 1) * i/n +  (dp[k][j][i] + 1) * j/n
こういうインデックスが面倒なことになるから1枚、2枚、3枚でなく1枚以上、2枚以上、3枚以上食べた種類の数で管理する
"""
"""
for i in range(n-1,-1,-1):
    for j in range(n-1,i-1,-1):
        for k in range(n-1,j-1,-1):
            
            ???
            dp[k][j][i] = (dp[k+1][j+1][i] + 1) * k/n +(dp[k+1][j+1][i+1] + 1) * j/n +  (dp[k][j][i] + 1) * i/n
            → dp[k][j][i] = ((dp[k+1][j+1][i] + 1) * k/(n-i) +(dp[k+1][j+1][i+1] + 1) * j/(n-i)) +   n/i
            """


#上の方針だと追えないのでやり直し。
#割り算が遅いと聞いてとりあえず試す
dp[n][n][n] = 0
divT = [1/i for i in range(1,n+1)]
def solve(x, y, z):
    if dp[x][y][z] != -1:
        return dp[x][y][z]
    else:
        delta = n*divT[n-z-1]#3枚以上ある皿以外を引くまで
        dp[x][y][z] = 0
        if x != n:
            dp[x][y][z] += (solve(x+1,y,z) + delta) * (n-x)*divT[n-z-1]
        if y != x:
            dp[x][y][z] += (solve(x,y+1,z) + delta) * (x-y)*divT[n-z-1]#x+1,y+1ではない
        if z != y:
            dp[x][y][z] += (solve(x,y,z+1) + delta) * (y-z)*divT[n-z-1]#x+1,y+1,z+1ではない
       
        return dp[x][y][z]


print(solve(cnt[1]+cnt[2], cnt[2] ,0))




### FIXED CODE ###

#http://compro.tsutajiro.com/archive/180220_probability_dp.pdf
import sys
n = int(input())
a = list(map(int, sys.stdin.readline().split( )))
cnt =[0,0,0]
for i in range(n):
    cnt[3-a[i]] += 1
dp = [[[0 for _ in range(n+1)] for __ in range(n+1)] for ___ in range(n+1)]

dp[n][n][n] = 0
divT = [1/i for i in range(1,n+1)]

for x in range(n,cnt[1]+cnt[2]-1,-1):## -2だったのを-1に
    for y in range(x,cnt[2]-1,-1):##cnt[2]
        for z in range(y,-1,-1):
            delta = n*divT[n-z-1]#2枚以下を引くまで
            if x != n:
                dp[x][y][z] += (dp[x+1][y][z] + delta) * (n-x)
            if y != x:
                dp[x][y][z] += (dp[x][y+1][z] + delta) * (x-y)#x+1,y+1ではない
            if z != y:
                dp[x][y][z] += (dp[x][y][z+1] + delta)* (y-z)#x+1,y+1,z+1ではない
            dp[x][y][z] *=divT[n-z-1]

print(dp[cnt[1]+cnt[2]][cnt[2]][0])
### BUGGY CODE ###

N, W = map(int, input().split())

INF = float("inf")
dp = [0] + [INF] * 10**5

for _ in range(N):
  w, v = map(int, input().split())
  for j in range(10**5, v-1, -1):
    dp[j] = min(dp[j], dp[j-v] + w)

for i, x in enumerate(dp):
  if x <= W:
    ans = i

print(ans)

### FIXED CODE ###

N, W = map(int, input().split())

INF = 10**11 + 1
dp = [[INF]*(10**5 + 1) for _ in range(N+1)]
dp[0][0] = 0

for i in range(N):
  w, v = map(int, input().split())
  for j in range(10**5 + 1):
    dp[i+1][j] = min(dp[i][j], dp[i][max(0, j-v)] + w)

ans = 0
    
for i, x in enumerate(dp[-1]):
  if x <= W:
    ans = i

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

def main():
    n = int(input())
    s = input()

    count_R = [0]
    count_G = [0]
    count_B = [0]
    d = {'R': count_R, 'G': count_G, 'B': count_B}
    for c in s:
        count_R.append(count_R[-1]+1) if c == 'R' else count_R.append(count_R[-1])
        count_G.append(count_G[-1]+1) if c == 'G' else count_G.append(count_G[-1])
        count_B.append(count_B[-1]+1) if c == 'B' else count_B.append(count_B[-1])

    res = 0
    for i in range(n-2):
        for k in range(i+1, n-1):
            if s[i] == s[k]:
                continue
            st = {'R', 'G', 'B'}
            st.discard(s[i])
            st.discard(s[k])
            c = st.pop()
            cnt = d[c]
            res += cnt[-1] - cnt[k]
            if k+k-i < n and s[k+k-i] == c:
                res -= 1

    print(res)

if __name__ == '__main__':
    main()


### FIXED CODE ###

n = int(input())
s = input()

count_R = [0]
count_G = [0]
count_B = [0]
d = {'R': count_R, 'G': count_G, 'B': count_B}
for c in s:
    count_R.append(count_R[-1]+1) if c == 'R' else count_R.append(count_R[-1])
    count_G.append(count_G[-1]+1) if c == 'G' else count_G.append(count_G[-1])
    count_B.append(count_B[-1]+1) if c == 'B' else count_B.append(count_B[-1])

res = 0
for i in range(n-2):
    for k in range(i+1, n-1):
        if s[i] == s[k]:
            continue
        st = {'R', 'G', 'B'}
        st.discard(s[i])
        st.discard(s[k])
        c = st.pop()
        cnt = d[c]
        res += cnt[-1] - cnt[k]
        if k+k-i < n and s[k+k-i] == c:
            res -= 1

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

import sys
import numpy as np
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

MOD = 10 ** 9 + 7
N=int(input())
A = [[int(x) for x in input().split()] for _ in range(N)]

dp = np.zeros(1<<N, dtype=np.uint32)
dp[0] = 1

for A_row in A:
    prev = dp.copy()
    dp = np.zeros_like(prev)
    for n,a in enumerate(A_row):
        if a == 0:
            continue
        x = 1<<n
        dp = dp.reshape(-1,2*x)
        prev = prev.reshape(-1,2*x)
        dp[:,x:] += prev[:,:-x]
        dp = dp.ravel()
        prev = prev.ravel()
        dp[dp >= MOD] -= MOD

answer = dp[-1]
print(answer)

### FIXED CODE ###

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

MOD = 10 ** 9 + 7
N = int(input())
A = [[int(x) for x in input().split()] for _ in range(N)]

bit_count = [0]
for _ in range(N):
    bit_count += [x+1 for x in bit_count]
    
dp = [0] * (1<<N)
dp[0] = 1

for i in range((1<<N)-1):
    k = bit_count[i]
    for c in range(N):
        if A[k][c]:
            dp[(1<<c)^i] += dp[i]

answer = dp[-1] % MOD
print(answer)
### BUGGY CODE ###

# C - XYZ Triplets
def get_f(n):
	count = 0
	
	for x in range(1, n):
		is_break = False
		
		if x ** 2 > n:
			return count
		else:
			for y in range(1, n):
				if is_break:
					break
				else:
					if x ** 2 + y ** 2 < n:
						for z in range(1, n):
							if is_break:
								break
							else:
								calc = x ** 2 + y ** 2 + x * y
						
								if calc < n:
									if z ** 2 + y * z + z * x == n - calc:
										count += 1
								else:
									is_break = True
		
	return count


N = int(input())

for n in range(1, N + 1):
	print(get_f(n))

### FIXED CODE ###

import sys
input = sys.stdin.readline

# C - XYZ Triplets
def calc(x, y, z):
	return x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x


N = int(input())
ans = [0] * (N + 1)

for x in range(1, 100):
	for y in range(1, 100):
		for z in range(1, 100):
			i = calc(x, y, z)
			
			if i > N:
				break
			else:
				ans[i] += 1

for i in range(1, N + 1):
	print(ans[i])
### BUGGY CODE ###

N = int(input())
A = [str(input()) for i in range(N)]
B = list(set(A))
B.sort()
Adict = {}
for i in range(len(B)):
  Adict[B[i]] = 0
for i in range(N):
  Adict[A[i]] += 1
ans = [x[0] for x in Adict.items() if x[1]==max(Adict.values())] 
for i in range(len(ans)):
  print(ans[i])

### FIXED CODE ###

import collections
 
N,*S = open(0).read().split()
C = collections.Counter(S)
 
i = C.most_common()[0][1]
print(*sorted([k for k,v in C.most_common() if v == i]), sep='\n')
### BUGGY CODE ###

N, K = map(int, input().split())
A = [int(i) for i in input().split()]
i_list = [0] * N

A_sum = A[0]
for i in range(K-1):
    if A[i+1] == 0:
        A_sum = 0
        break
    else:
        A_sum = A_sum * A[i+1]
i_list[K-1] = A_sum
cnt = 0

for k in range(K, N):
    i_list[k] = i_list[k-1] // A[cnt] * A[k]
    cnt = cnt + 1
    if i_list[k-1] < i_list[k]:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

N, K = map(int, input().split())
A = [int(i) for i in input().split()]
i_list = [0] * N

for i in range(K, N):
    if A[i-K] < A[i]:
        print('Yes')
    else:
        print('No')