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

import numpy as np
q = list(map(int, input().split()))
w= list(map(int, input().split()))
memo=0
a=0
x=np.array(w)
for i in range(q[0]-q[1]+1):
  k=0
  for j in range(q[1]):
    k+=x[i+j]
  if a<k:
    a=k
    memo=i
print((a+q[1])/2)

### FIXED CODE ###

n,k= list(map(int, input().split()))
j = list(map(int, input().split()))
s=0
sumlist=[0]*(n+1)
anslist=[0]*(n-k+1)
for i in range(n):
    s+=j[i]
    sumlist[i+1]=s
for i in range(len(anslist)):
     z=sumlist[i+k]-sumlist[i]
     anslist[i]=z
ans=max(anslist)
ans+=k
ans=ans/2
print(ans)
### BUGGY CODE ###

import sys

input = sys.stdin.buffer.readline

n, s = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
dp = [[{} for _ in range(s + 1)] for _ in range(n + 1)]
dp[0][0][0] = 1
kiroku = [0] * (n)

for i in range(n):
    ni = i + 1
    for j in range(s + 1):
        nj = j
        if dp[i][j] == {}:
            continue
        for key, val in dp[i][j].items():
            if key in dp[ni][nj]:
                dp[ni][nj][key] += val
            else:
                dp[ni][nj][key] = val
        nj = j + A[i]
        if nj <= s:
            for key, val in dp[i][j].items():
                if key + 1 in dp[ni][nj]:
                    dp[ni][nj][key + 1] += val
                else:
                    dp[ni][nj][key + 1] = val
ans = 0
for key, val in dp[n][s].items():
    if key == 0:
        continue
    ans += pow(2, n - key) * val
    ans %= mod
print(ans)


### FIXED CODE ###

import sys

input = sys.stdin.buffer.readline

n, s = map(int, input().split())
A = list(map(int, input().split()))
mod = 998244353
dp = [[0] * (s + 1) for _ in range(n + 1)]
dp[0][0] = 1

for i in range(n):
    ni = i + 1
    for j in range(s + 1):
        nj = j
        dp[ni][nj] += 2 * dp[i][j]
        dp[ni][nj] %= mod
        nj = j + A[i]
        if nj <= s:
            dp[ni][nj] += dp[i][j]
            dp[ni][nj] %= mod
print(dp[n][s] % mod)
### BUGGY CODE ###

#!python3

iim = lambda: map(int, input().rstrip().split())

from bisect import bisect

def resolve():
    def find(i):
        x = S[i]
        while True:
            k = S[i][0]
            if k == i:
                x[0] = i
                return i
            S[i] = x
            i = k
    def join(i, j):
        ai = find(i)
        aj = find(j)
        if ai != aj:
            #S[aj][0] = S[ai][0]
            S[aj] = S[ai]
    def same(i, j):
        ai = find(i)
        aj = find(j)
        return ai == aj

    N, M, K = iim()
    S = [[i] for i in range(N+1)]
    mk = set()
    for i in range(M):
        ai, bi = iim()
        if ai > bi:
            ai, bi = bi, ai
        join(ai, bi)
        mk.add((ai, bi))
    for i in range(K):
        ai, bi = iim()
        if ai > bi:
            ai, bi = bi, ai
        mk.add((ai, bi))

    ans = [0] * (N+1)
    #print(S)
    for i in range(1, N):
        aa = 0
        for j in range(i+1, N+1):
            if (i, j) in mk:
                continue
            if same(i, j):
                ans[i] += 1
                ans[j] += 1
    print(*ans[1:])



if __name__ == "__main__":
    resolve()


### FIXED CODE ###

#!python3

iim = lambda: map(int, input().rstrip().split())

from bisect import bisect

def resolve():
    def find(i):
        x = S[i]
        if x < 0:
            return i
        S[i] = find(x)
        return S[i]

    def join(i, j):
        ai = find(i)
        aj = find(j)
        diff = ai - aj
        #print("j", ai, aj)
        if diff == 0:
            return
        elif diff > 0:
            ai, aj = aj, ai
        S[ai] += S[aj]
        S[aj] = ai
    def same(i, j):
        ai = find(i)
        aj = find(j)
        return ai == aj
    def size(i):
        return -S[find(i)]

    N, M, K = iim()
    S = [-1] * N
    T = [1] * N
    for i in range(M):
        ai, bi = iim()
        ai -= 1; bi -= 1
        join(ai, bi)
        T[ai] += 1
        T[bi] += 1
        #print(ai, bi, S)

    U = [set() for i in range(N)]
    for i in range(K):
        ai, bi = iim()
        ai -= 1; bi -= 1
        U[ai].add(bi)
        U[bi].add(ai)
    #print(S)
    #print(T)

    ans = [size(i) - T[i] - sum(same(i, j) for j in U[i]) for i in range(N)]
    print(*ans)


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

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

s=[0]*n

for i in range(m):
    l,r=map(int,input().split())
    x=l
    while x<=r:
        s[x-1]+=1
        x+=1
        
ans=[str(i) for i in s] 
print(ans.count(str(m)))

### FIXED CODE ###

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

s=[0]*n
left=[]
right=[]
for i in range(m):
    l,r=map(int,input().split())
    left.append(l)
    right.append(r)
    
if min(right)<max(left):
    print(0)
else:
    print(min(right)-max(left)+1)
### BUGGY CODE ###

N,K=map(int,input().split())
P=list(map(int,input().split()))
ans=0
for i in range(N-K+1):
    kitai=0
    for j in range(K):
        kitai+=((P[i+j]+1)/2)
    ans=max(ans,kitai)
print(ans)

### FIXED CODE ###

N,K=map(int,input().split())
P=list(map(int,input().split()))
mx=sm=sum(P[:K])
for i in range(N-K):
    sm=sm+P[i+K]-P[i]
    mx=max(mx,sm)
print((mx+K)/2)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

def table(n:int, p=10**9+7):
    global fact, factinv, inv
    fact = [1, 1]
    factinv = [1, 1]
    inv = [0, 1]
    for i in range(2, n+1):
        #fact.append((fact[-1] * i) % p)
        inv.append((-inv[p % i] * (p // i)) % p)
        #factinv.append((factinv[-1] * inv[-1]) % p)

m, a, b = mi()

P = 10**9+7
N = 2*(10**5)
table(N)

mca = 1
for i in range(1, a+1):
    #mca *= (m-i+1) * inv[i]
    mca *= (m-i+1) * pow(i, P-2, P)
    mca %= P

mcb = mca
for i in range(a+1, b+1):
    #mcb *= (m-i+1) * inv[i]
    mca *= (m-i+1) * pow(i, P-2, P)
    mcb %= P

print((pow(2, m, P)-1-mca-mcb) % P)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

m, a, b = mi()

P = 10**9+7
N = 2*(10**5)+1
inv_t = [0]+[1]
for i in range(2,N):
  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

mca = mcb = 1

for i in range(1, a+1):
    mca *= (m-i+1) * inv_t[i]
    mca %= P

for i in range(1, b+1):
    mcb *= (m-i+1) * inv_t[i]
    mcb %= P

print(((2**m)-mca-mcb-1)%P)
### BUGGY CODE ###

n, k = map(int, input().split())
a = [int(i) for i in input().split()]
ordi = [0, ]
for i in range(n):
    if a[ordi[-1]] - 1 not in ordi:
        ordi.append(a[ordi[-1]] - 1)
    else:
        ordi.append(a[ordi[-1]] - 1)
        index = ordi.index(a[ordi[-2]] - 1)
        len_ = len(ordi) - 1 - index
        break
print(ordi[index + (k - index) % len_] + 1 if index <= k else ordi[k] + 1)

### FIXED CODE ###

from copy import copy
n, k = map(int, input().split())
a = [int(i) - 1 for i in input().split()]
ans = 0
while k:
    if k & 1:
        ans = a[ans]
    c = [a[a[i]] for i in range(n)]
    a = copy(c)
    k >>= 1
print(ans + 1)
### BUGGY CODE ###

N, Q = map(int, input().split())
G = [[] for _ in range(N)]
memo = [[i] for i in range(N)]
flg = [False]*N
for i in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)

ans = [0]*N

for i in range(Q):
    p, x = map(int, input().split())
    if not flg[p-1]:
        flg[p-1] = True
        ans[p-1] += x
        queue = [p-1]
        while queue:
            par = queue.pop(0)
            if G[par]:
                for i in G[par]:
                    ans[i] += x
                    queue.append(i)
                    memo[p-1].append(i)
    else:
        for i in memo[p-1]:
            ans[i] += x

print(*ans)

### FIXED CODE ###

N, Q = map(int, input().split())
G = [[] for _ in range(N)]
ans = [0]*N

for _ in range(N-1):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

for _ in range(Q):
    p, x = map(int, input().split())
    ans[p-1] += x

judge = [False]*N
judge[0] = True
queue = [0]
while queue:
    a = queue.pop()
    for i in G[a]:
        if not judge[i]:
            judge[i] = True
            ans[i] += ans[a]
            if G[i]:
                queue.append(i)

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

N = int(input())
# n, *a = map(int, open(0))
# M, D = map(int, input().split())
L = list(map(int, input().split()))
# S = input()
cnt = 0
import itertools
import numpy as np
l = list(itertools.combinations(L, 2))
l2 = []
for t in l:
    l2.append(sum(t))
ary = np.array(l2)
# ary = np.array(L)
for i in L:
    # if t[0] + t[1] > t[2] and t[1] + t[2] > t[0] and t[0] + t[2] > t[1]:
    cnt += np.count_nonzero(ary <= i)
tot = (N * (N-1) * (N-2)) // 6
print(tot - cnt)


### FIXED CODE ###

N=int(input())
L=list(map(int,input().split()))
L.sort()
ans = 0
i = 0
while i < N - 2:
    j = i + 1
    k = j + 1
    while j < N - 1:
        while k < N:
            if L[i] + L[j] <= L[k]:
                ans += k - j - 1
                break
            k += 1
        if k == N:
            ans += k - 1 - j
        j += 1
    i += 1
print(ans)
### BUGGY CODE ###

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

count = N
Sum = 0

for l in range(0, N-1):
    Sum = A[l]
    r = l+1
    while r < N and Sum + A[r] == Sum ^ A[r]:
            Sum += A[r]
            r += 1
    count += r-l-1
    
print(count)

### FIXED CODE ###

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

count = 0
Sum = 0
r = 0

for l in range(0, N):
    #Sum = A[l]
    while r < N and Sum + A[r] == Sum ^ A[r]:
            Sum += A[r]
            r += 1
    count += r-l
    if(l==r):
        r+=1
    else:
        Sum -= A[l]
    
    
print(count)
### BUGGY CODE ###

n=int(input())
s=list(map(int,input().split()))
count=0
for i in range(n):
  a=s[i]
  b=abs(s[i]-i-1)
  for j in range(b,n):
    if abs(i-j)==(s[i]+s[j]):
      count+=1
print(count)

### FIXED CODE ###

import collections
n=int(input())
s=list(map(int, input().split()))
L=[i+a for i,a in enumerate(s)]
R=[i-a for i,a in enumerate(s)] 
t=collections.Counter(L)
u=collections.Counter(R)
ans = 0
for i in t.keys():
  ans+=t[i]*u[i]
print(ans)
### BUGGY CODE ###

import collections
from functools import reduce
from operator import mul


def trial_division(n):
    l = []
    f = 2
    while n > 1:
        if (n % f == 0):
            l.append(f)
            n /= f
        else:
            f += 1
    return l


def combinations_count(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    return reduce(mul, range(n, n - r, -1)) // reduce(mul, range(r, 0, -1))


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

c = collections.Counter(trial_division(M))
a = 1
for i in c.values():
    a *= combinations_count(i + N - 1, i)

print(a % (10**9 + 7))

### FIXED CODE ###

import collections
from functools import reduce
from operator import mul


def trial_division(n):
    l = []
    f = 2
    while f * f <= n:
        if n % f == 0:
            l.append(f)
            n //= f
        else:
            f += 1
    if n > 1:
        l.append(n)
    return l


def combinations_count(n, r):
    r = min(n - r, r)
    if r == 0:
        return 1
    return reduce(mul, range(n, n - r, -1)) // reduce(mul, range(r, 0, -1))


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

c = collections.Counter(trial_division(M))
a = 1
for i in c.values():
    a *= combinations_count(i + N - 1, i)

print(a % (10**9 + 7))
### BUGGY CODE ###

import itertools

def main():
    N, M, R = map(int, input().split())
    RR = tuple(map(int, input().split()))
    ABC = {tuple(map(int, input().split())) for _ in range(M)}

    dist = [[float('inf') for i in range(N + 1)] for j in range(N + 1)]
    for a, b, c in ABC:
        dist[a][b] = dist[b][a] = c
    for k in range(1, N + 1):
        for i in range(1, N + 1):
            for j in range(1, N + 1):
                dist[i][j] = dist[i][j] if dist[i][j] < dist[i][k] + dist[k][j] else dist[i][k] + dist[k][j]

    ans = float('inf')
    for r in itertools.permutations(RR):
        move = 0
        for i in range(R - 1):
            a = r[i]
            b = r[i+1]
            move += dist[a][b]
        ans = ans if ans < move else move

    print(ans)

main()


### FIXED CODE ###

import itertools

def main():
    N, M, R = map(int, input().split())
    RR = tuple(map(int, input().split()))
    ABC = {tuple(map(int, input().split())) for _ in range(M)}

    dist = [[float('inf')] * (N + 1) for j in range(N + 1)]
    for a, b, c in ABC:
        dist[a][b] = dist[b][a] = c
        dist[a][a] = dist[b][b] = 0
    for k in range(1, N + 1):
        for i in range(1, N + 1):
            for j in range(1, N + 1):
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

    ans = float('inf')
    for r in itertools.permutations(RR):
        move = 0
        for i in range(R - 1):
            a = r[i]
            b = r[i+1]
            move += dist[a][b]
        ans = min(ans, move)

    print(ans)

main()
### BUGGY CODE ###

sn,qn=map(int,input().split())
s=input()
x=list(list(map(int,input().split())) for _ in range(qn))

for i in range(qn):
	s2=s[x[i][0]-1:x[i][1]]
	print(s2.count('AC'))

### FIXED CODE ###

sn,qn=map(int,input().split())
s=input()
x=list(list(map(int,input().split())) for _ in range(qn))

s2=[0]*sn

for i in range(sn-1):
	if s[i]=='A' and s[i+1]=='C':
		s2[i+1]=s2[i]+1
	else:
		s2[i+1]=s2[i]

for i in range(qn):
	res=s2[x[i][1]-1]-s2[x[i][0]-1]
	print(res)
### BUGGY CODE ###

import collections
n=int(input())
a=collections.OrderedDict()
for i in range(n):
    tmp=input()
    if not tmp in a:
        a[tmp] = 1
    else:
        a[tmp] += 1
a = collections.OrderedDict(
    sorted(a.items(), key=lambda x: x[0])
)
for k, v in a.items():
    if v == max(a.values()):
        print(k)

### FIXED CODE ###

n=int(input())
a={}
for i in range(n):
    tmp=input()
    if not tmp in a:
        a[tmp] = 1
    else:
        a[tmp] += 1
M=max(a.values())
ans=[]
for k, v in a.items():
    if v == M:
        ans.append(k)
ans.sort()
for i in range(len(ans)):
    print(ans[i])
### BUGGY CODE ###

import sys
input == sys.stdin.readline

def main():
    #1:初期化
    N,W = map(int,input().split())
    wv = []
    for _ in range(N):
        wv.append(list(map(int,input().split())))
    dp = [[0]*(W+1) for i in range(N+1)]

    #print(wv)
    #print(dp)
    #2:初期値(元からゼロなので記述無し)

    #3:dp実行部(貰うDP)
    for i in range(1,N+1):
        for j in range(1,W+1):
            if wv[i-1][0] <= j:
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-wv[i-1][0]]+wv[i-1][1])
            else:
                dp[i][j] = dp[i-1][j]
            #print(i,j)
            #print(*dp,sep="\n")

    #4:出力
    print(dp[N][W])

if __name__ == '__main__':
    main()

### FIXED CODE ###

"""memo
    numpyでやるときは配列を一気に更新するが(numpy使いたくないのでやらない)，
    このやり方は後ろの方から更新することで後の更新に影響を与えない(考え方すごい)．
    (参考#9889377)
"""

import sys
input = sys.stdin.readline

def main():
    #1:初期化
    N,W = map(int,input().split())
    dp = [0]*(W+1)

    #2:初期値(元からゼロなので記述無し)

    #3:dp実行部(貰うDP)
    for i in range(N):
        w, v = map(int,input().split())
        for i in range(W, w-1, -1):
            tmp = dp[i-w] + v
            if dp[i] < tmp:
                dp[i] = tmp
        #print(dp,sep="\n")

    #4:出力
    print(max(dp))

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

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

d = [0]*60
for ai in aa:
  for e,i in enumerate(bin(ai)[:1:-1]):
    d[e]+=int(i) 

ans = 0
for i in range(len(d)):
  if d[i]==0 or d[i]==n:
    pass
  else:     
    #print(d[i]*(n-d[i])* 2**(i))    
    ans += d[i]*(n-d[i])* 2**(i)
    ans %= (10**9+7)
    
print(ans)    

### FIXED CODE ###

## D
MOD = 10**9 + 7
n = int(input())
A = list(map(int,input().split()))

m = 1
ans = 0
for i in range(60):
  s = sum([a&m for a in A])
  s//=m
  ans = (ans + (n-s)*s * m) % MOD
  m <<= 1
  
print(ans)
### BUGGY CODE ###

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

m = n//2
INF = 10**18
dp = [[-INF]*(m+1) for _ in range(n+1)]
for i in range(1, n+1):
    L = i//2-1
    R = (i+1)//2+1
    for j in range(L, R):
        if j == 1:
            dp[i][j] = max(dp[i-1][j], A[i-1])
        elif 0 <= i-2 and 0 <= j <= m:
            dp[i][j] = max(dp[i-1][j], dp[i-2][j-1]+A[i-1])
print(dp[-1][m])



### FIXED CODE ###

from collections import defaultdict
n = int(input())
A = list(map(int, input().split()))
m = n//2
INF = 10**18
dp = [defaultdict(lambda: -INF) for _ in range(n+1)]
for i in range(1, n+1):
    L = i//2-1
    R = (i+1)//2+1
    for j in range(L, R):
        if j == 1:
            dp[i][j] = max(dp[i-1][j], A[i-1])
        elif 0 <= i-2 and 0 <= j <= m:
            dp[i][j] = max(dp[i-1][j], dp[i-2][j-1]+A[i-1])
print(dp[-1][m])
### BUGGY CODE ###

n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
import sys
import math
def setwise_coprime(a):
  ans=a[0]
  for i in range(1,n):
    ans=math.gcd(ans,a[i])
  return ans

ruiseki=1

if setwise_coprime(a)==1:
  for i in range(n):
    ruiseki=ruiseki*a[i]
  for i in range(n):
    num=math.gcd(a[i],(ruiseki//a[i])%a[i])
    if num!=1:
      print("setwise coprime")
      sys.exit()
  print("pairwise coprime")
else:
  print("not coprime")
  sys.exit()


        












### FIXED CODE ###

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

import sys
import math
def setwise_coprime(a):
  ans=a[0]
  for i in range(1,n):
    ans=math.gcd(ans,a[i])
  return ans

#エラストテネスのふるい
def create_sieve(n):
  sieve=[0]*(n+1)
  for i in range(2,n+1):
    if sieve[i]==0:
      for j in range(i*i,n+1,i):
        sieve[j]=i
  return sieve

#高速素因数分解
def fast_factorization(n, sieve):
  prime={}
  while n>1:
    p=sieve[n]
    #nが素数の場合
    if p==0:
      prime[n]=prime.get(n,0)+1
      break
    #nが素数ではない場合
    else:
      prime[p]=prime.get(p,0)+1
      n=n//p
  return prime

check=set()
if setwise_coprime(a)==1:
  #素因数のダブリをcheck
  sieve=create_sieve(10**6)
  for i in range(n):
    if a[i]!=1:
      s=fast_factorization(a[i], sieve)
      for i in s:
        if i in check:
          print("setwise coprime")
          sys.exit()
        else:
          check.add(i)
  print("pairwise coprime")    
else:
  print("not coprime")
### BUGGY CODE ###

from operator import itemgetter


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

INF = 10**18
dp = [[INF] * (1 << n) for i in range(n)]
for i in range(n):
    dp[i][1 << i] = i

for bit_state in range(1 << n):
    for i in range(n):
        if not(bit_state & (1 << i)):
            continue
        for j in range(n):
            if bit_state & (1 << j):
                continue
            cnt0 = bin((bit_state & ((1 << j) - 1)) + (1 << j)).count("0") - 1
            cnt1 = bin(bit_state).count("1")
            
            num_i = a[i] if (cnt1 - 1) % 2 == i % 2 else b[i]
            num_j = a[j] if (cnt1) % 2 == j % 2 else b[j]

            if num_i <= num_j:
                dp[j][bit_state | (1 << j)] = min(dp[j][bit_state | (1 << j)], dp[i][bit_state] + cnt0)

ans = 10**18
for i in range(n):
    ans = min(ans, dp[i][-1]) 
if ans == 10**18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

# Binary Indexed Tree (Fenwick Tree)
class BIT():
    """一点加算、区間取得クエリをそれぞれO(logN)で答える
    add: i番目にvalを加える
    get_sum: 区間[l, r)の和を求める
    i, l, rは0-indexed
    """
    def __init__(self, n):
        self.n = n
        self.bit = [0] * (n + 1)

    def _sum(self, i):
        s = 0
        while i > 0:
            s += self.bit[i]
            i -= i & -i
        return s

    def add(self, i, val):
        """i番目にvalを加える"""
        i = i + 1
        while i <= self.n:
            self.bit[i] += val
            i += i & -i

    def get_sum(self, l, r):
        """区間[l, r)の和を求める"""
        return self._sum(r) - self._sum(l)


from operator import itemgetter
from collections import deque

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 10**18


for bit_state in range(1 << n):
    pattern = [[] for i in range(2)]
    for i in range(n):
        if bit_state & (1 << i) and i % 2 == 0:
            pattern[0].append(a[i]*100 + i)
        elif bit_state & (1 << i) and i % 2 == 1:
            pattern[1].append(a[i]*100 + i)
        elif i % 2 == 0:
            pattern[1].append(b[i]*100 + i)
        else:
            pattern[0].append(b[i]*100 + i)

    if len(pattern[0]) == len(pattern[1]) or len(pattern[0]) - 1 == len(pattern[1]):
        for i in range(2):
            pattern[i] = sorted(pattern[i])
        bit = BIT(n)
        ans_tmp = 0
        prev_num = 10**8
        for i in range(n)[::-1]:
            pal = i % 2
            num = pattern[pal].pop()
            ind = num % 100
            num = num // 100
            if prev_num < num:
                break
            prev_num = num
            bit.add(ind, 1)
            ans_tmp += bit.get_sum(0, ind)
        else:
            ans = min(ans, ans_tmp)

if ans == 10**18:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

n = int(input())
s = input()
d = {'R':0,'G':0,'B':0}
for i in s:
    d[i] += 1
c = d['R'] * d['G'] * d['B']

for i in range(n):
    for j in range(i+1,n):
        k = 2 * j - i
        if(k <= j or k >= n):continue
        if(s[i] != s[j] and s[j] != s[k] and s[i] != s[k]):c -= 1

print(c)

### FIXED CODE ###

n = int(input())
s = input()
d = [0,0,0]
for i in s:
    if(i == 'R'):d[0] += 1
    elif(i == 'G'):d[1] += 1
    elif(i == 'B'):d[2] += 1
c = d[0] * d[1] * d[2]

for i in range(n):
    for j in range(i+1,n):
        k = 2 * j - i
        if(k >= n):continue
        if(s[i] == s[j]):continue
        if(s[j] == s[k]):continue
        if(s[i] == s[k]):continue
        c -= 1

print(c)
### BUGGY CODE ###

s = [s_i for s_i in input()]
i = ans = 0
while i < len(s) - 1:
    if s[i] == "B" and s[i+1] == "W":
        ans += 1
        s[i] = "W"
        s[i+1] = "B"
        if i == 0: continue
        else: i -= 1
    else: i += 1
print(ans)

### FIXED CODE ###

s = [1 if x == "B" else 0 for x in input()]
ans = cnt = 0
for s_i in s:
    if s_i == 1: cnt += 1
    else: ans += cnt
print(ans)