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

n, k = map(int,input().split())
p = list(map(int,input().split()))

max_val = 0
for ind in range(n-k+1):
  cur_val = sum(p[ind:ind+k])
  max_val = max(max_val,cur_val)
max_val = float(max_val)
k = float(k)
print(max_val/2+k/2)

### FIXED CODE ###

n, k = map(int,input().split())
p = list(map(int,input().split()))

exps = [(elm+1)/2 for elm in p]
#print(exps)
cum_sums = [0]*(n+1)
for ind in range(n):
  cum_sums[ind+1] = cum_sums[ind]+exps[ind]
#print(cum_sums)
k_exps = [cum_sums[ind+k]-cum_sums[ind] for ind in range(n-k+1)]
#print(k_exps)
print(max(k_exps))
### BUGGY CODE ###

import sys
from pprint import pprint

sys.setrecursionlimit(4100000)

B = 10


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(N, M, inputs):
    jobs = list(map(string_to_int, inputs))
    jobs.sort(key=lambda x: (x[0]))

    money = 0
    for day in range(1, M + 1):
        max_money = 0
        max_i = -1
        for i, j in enumerate(jobs):
            if j[0] > day:
                break
            if max_money < j[1]:
                max_money = j[1]
                max_i = i
        if max_i != -1:
            money += max_money
            jobs.pop(max_i)

    return money


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    [N, M] = string_to_int(input())
    ret = solve(N, M, inputs(N))
    print(ret)


### FIXED CODE ###

import sys
from pprint import pprint
import heapq

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(N, M, inputs):
    jobs = list(map(string_to_int, inputs))
    jobs.sort(key=lambda x: x[0], reverse=True)
    selectable = []
    money = 0
    for day in range(1, M + 1):
        while len(jobs) != 0 and jobs[-1][0] <= day:
            heapq.heappush(selectable, jobs.pop()[1] * -1)
        if len(selectable) != 0:
            money += heapq.heappop(selectable) * -1
    return money


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    [N, M] = string_to_int(input())
    ret = solve(N, M, inputs(N))
    print(ret)
### BUGGY CODE ###

N = int(input())
ab = []
abn = [0]*N
abw = [[] for _ in range(N)]
for i in range(N-1):
  a,b = list(map(int,input().split()))
  ab.append([a,b])
  abw[a-1].append(b)
  abw[b-1].append(a)
  abn[a-1] += 1
  abn[b-1] += 1
c = sorted(list(map(int,input().split())))
cn = 0
d = [0]*N
s = [i for i in range(N)]
while cn <N:
  cut = []
  for i in s:
    if (abn[i] == 1 and cn<N) or len(s) == 1:
      d[i] = c[cn]
      cn += 1
      cut.append(i)
      abn[i] -=1
      s.remove(i)
  for j in cut:
    for k in abw[j]:
      abn[k-1] -= 1
print(sum(c)-max(c))
print(" ".join(map(str,d)))

### FIXED CODE ###

N = int(input())
ab = []
abn = [0]*N
abw = [[] for _ in range(N)]
for i in range(N-1):
  a,b = list(map(int,input().split()))
  ab.append([a,b])
  abw[a-1].append(b)
  abw[b-1].append(a)
  abn[a-1] += 1
  abn[b-1] += 1
c = sorted(list(map(int,input().split())))
cn = 0
d = [0]*N
s = [i for i in range(N)]
while cn <N:
  cut = []
  for i in s:
    if (abn[i] == 1 and cn<N) or len(s) == 1:
      d[i] = c[cn]
      cn += 1
      cut.append(i)
      abn[i] -=1
      s.remove(i)
  for j in cut:
    for k in abw[j]:
      abn[k-1] -= 1
print(sum(c)-max(c))
print(" ".join(map(str,d)))
### BUGGY CODE ###

n = int(input())

if n == 1:
    print(0)
else:
    print(sum(range(1, n)))

### FIXED CODE ###

n = int(input())

print(n * (n - 1) // 2)
### BUGGY CODE ###

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

def popcount(i):
    return bin(i).count('1')

N = INT()
X = int(input(), 2)

for i in range(N-1, -1, -1):
    cur = X ^ (1<<i)
    cnt = 0
    while cur:
        cur %= popcount(cur)
        cnt += 1
    print(cnt)


### FIXED CODE ###

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

def popcount(i):
    return bin(i).count('1')

N = INT()
S = list(map(int, input()))[::-1]

pcnt1 = S.count(1) - 1
pcnt2 = S.count(1) + 1
base1 = base2 = 0
for i in range(N):
    if S[i]:
        if pcnt1 != 0:
            base1 += pow(2, i, pcnt1)
        base2 += pow(2, i, pcnt2)

ans = [0] * N
for i in range(N):
    if S[i] and pcnt1 == 0:
        ans[i] = 0
        continue
    cur = 0
    if S[i]:
        cur += (base1 - pow(2, i, pcnt1)) % pcnt1
    else:
        cur += (base2 + pow(2, i, pcnt2)) % pcnt2
    cnt = 1
    while cur:
        cur %= popcount(cur)
        cnt += 1
    ans[i] = cnt
for a in ans[::-1]:
    print(a)
### BUGGY CODE ###

def main():
    from builtins import int, map, list, print
    from collections import defaultdict
    from bisect import bisect_left
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number = (lambda: int(input()))
    input_number_list = (lambda: list(map(int, input_list())))

    N,M = input_number_list()
    P = []
    Y = []
    city = defaultdict(list)
    for i in range(M):
        p,y = input_number_list()
        P.append(p)
        Y.append(y)
        city[p].insert(bisect_left(city[p],y),y)
    for i in range(M):
        print('{:06}{:06}'.format(P[i],city[P[i]].index(Y[i])+1))
if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    from builtins import int, map, list, print
    from collections import defaultdict, deque
    from bisect import bisect_left
    import sys
    sys.setrecursionlimit(10 ** 6)

    input = sys.stdin.readline
    input_list = (lambda: input().rstrip().split())
    input_number_list = (lambda: list(map(int, input_list())))

    N, M = input_number_list()
    pref = [[0] for i in range(N + 1)]
    q = deque()
    for i in range(M):
        p, y = map(int, input_number_list())
        pref[p].append(y)
        q.append((p, y))
    for p in pref:
        p.sort()
    for p, y in q:
        print('{:06}{:06}'.format(p, bisect_left(pref[p], y)))


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

N=int(input())
P=list(map(int,input().split()))
count=0
flag=True
for i in range(N):
    for k in range(i):
        l=min(P[:i])
        if P[i]>l:
            flag=False
            break
    if flag:
        count+=1
    else:
        flag=True
print(count)


### FIXED CODE ###

N=int(input())
P=list(map(int,input().split()))
count=1
min=P[0]
for i in range(1,N):
    if min>P[i]:
      count+=1
      min=P[i]
print(count)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

import sys
import math

def main():
    input = sys.stdin.readline
    N = int(input())

    result = 0
    ok_flag = False
    for n in range(1,N+1):
        root_n = int(math.sqrt(n)) + 1
        if n < 3:
            print(0) 
            continue
        for i in range(1,root_n):
            for j in range(1,root_n):
                for k in range(i,root_n):
                    if i*i + j*j + k*k + i*j + i*k + j*k == n:
                        if i == j and j == k:
                            result += 1
                        elif i == j or j == k or i == k:
                            result += 3
                        else:
                            result += 6
                        print(result)
                        result = 0
                        ok_flag = True
                        break
                if ok_flag:
                    break
            if ok_flag:
                break

        if not ok_flag:
            print(0)
        ok_flag = False
        
                        

    return


if __name__ == '__main__':
    main()

### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys
import math

def main():
    input = sys.stdin.readline
    N = int(input())

    result = 0
    ans_list = [0]*(N+1)
    root_n =int(math.sqrt(N))+1

    for i in range(1,root_n):
        for j in range(1,root_n):
            for k in range(1,root_n):
                f = i**2+j**2+k**2+i*j+i*k+j*k
                if f <= N:
                    ans_list[f] += 1 
    
    for i in range(1,N+1):
        print(ans_list[i])
        
                        

    return


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

[n, k, q] = list(map(int, input().split()))
a = []
for i in range(q):
    a.append(list(map(int, input().split()))[0])
    
import numpy as np

player = [k] * n
player = np.array(player)

for _a in a:
    player[_a-1] += 1
    player -= 1
           
for _p in player:
    if _p > 0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

[n, k, q] = list(map(int, input().split()))
a = []
for i in range(q):
    a.append(list(map(int, input().split()))[0])
    
import numpy as np

player = [k] * n
player = np.array(player)

for _a in a:
    player[_a-1] += 1
    
player -= q
           
for _p in player:
    if _p > 0:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(61):
    N1 = 0
    N1 = sum(1 for a in A if ( (a >> k) & 1))
    ans += (((1<<k)) *(N-N1) *N1)
    ans %= M    

print(int(ans))

### FIXED CODE ###

M = 10**9+7
N = int(input())
A = list(map(int,input().split()))

ans = 0
for k in range(61):
    N1 = 0
    N1 = sum([1 for a in A if ( (a >> k) & 1)])
    ans += (((1<<k)) *(N-N1) *N1)
    ans %= M    

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


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

total = 1
flag = 0
for i in range(len(inputs)):
    total = total * inputs[i]

if total > 10 ** 18:
    print(-1)
else:
    print(total)

### FIXED CODE ###

N = int(input())
inputs = list(map(int, input().split()))
#print(inputs)
total = 1
flag = 0
if 0 in inputs:
    print('0')
else:
    for i in range(len(inputs)):
        total = total * inputs[i]
        if total > 10 ** 18:
            print('-1')
            flag = 1
            break
    if flag == 0:
        print(total)
### BUGGY CODE ###

from collections import defaultdict
n,k = map(int,input().split())
mod = 924844033
rng = 2010
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod
if (n-k)*2 <= n:
  x = (n-k)*2
  ans = 0
  for i in range(x+1):
    if i%2 == 0:
      ans += cmb(x,i)*fctr[n-i]
    else:
      ans -= cmb(x,i)*fctr[n-i]
    ans %= mod
  print(ans)
  exit()
dc = defaultdict(int)
for j in range(1,k+1):
  a = j
  b = k+j
  cnt = 0
  while a<=n and b<=n:
    if a>b:
      b += 2*k
    else:
      a += 2*k
    cnt += 1
  dc[cnt] += 2
nn = (n-k)*2
cp = set()
cpp = 1
for i,x in dc.items():
  for j in range(x):
    cpp += i
    cp.add(cpp)
cp.add(1)
dp = [[0 for j in range(n+1)] for i in range(nn+1)]
dp[0][0] = 1
for i in range(1,nn+1):
  dp[i] = dp[i-1][:]
  if i not in cp:
    for j in range(1,min(i,n)+1):
      dp[i][j] += dp[i-2][j-1]
  else:
    for j in range(1,min(i,n)+1):
      dp[i][j] += dp[i-1][j-1]
  dp[i][j] %= mod
ans = 0
for i in range(n+1):
  if i%2 == 0:
    ans += fctr[n-i]*dp[nn][i]
  else:
    ans -= fctr[n-i]*dp[nn][i]
  ans %= mod
print(ans)

### FIXED CODE ###

from collections import defaultdict
n,k = map(int,input().split())
mod = 924844033
rng = 2010
fctr = [1]
finv = [1]
for i in range(1,rng):
  fctr.append(fctr[-1]*i%mod)
for i in range(1,rng):
  finv.append(pow(fctr[i],mod-2,mod))
def cmb(n,k):
  if n<0 or k<0:
    return 0
  else:
    return fctr[n]*finv[n-k]*finv[k]%mod
if (n-k)*2 <= n:
  x = (n-k)*2
  ans = 0
  for i in range(x+1):
    if i%2 == 0:
      ans += cmb(x,i)*fctr[n-i]
    else:
      ans -= cmb(x,i)*fctr[n-i]
    ans %= mod
  print(ans)
  exit()
dc = defaultdict(int)
for j in range(1,k+1):
  a = j
  b = k+j
  cnt = 0
  while a<=n and b<=n:
    if a>b:
      b += 2*k
    else:
      a += 2*k
    cnt += 1
  dc[cnt] += 2
nn = (n-k)*2
cp = set()
cpp = 1
for i,x in dc.items():
  for j in range(x):
    cpp += i
    cp.add(cpp)
cp.add(1)
dp = [[0 for j in range(n+1)] for i in range(nn+1)]
dp[0][0] = 1
for i in range(1,nn+1):
  dp[i] = dp[i-1][:]
  if i not in cp:
    for j in range(1,min(i,n)+1):
      dp[i][j] += dp[i-2][j-1]
      dp[i][j] %= mod
  else:
    for j in range(1,min(i,n)+1):
      dp[i][j] += dp[i-1][j-1]
      dp[i][j] %= mod
ans = 0
for i in range(n+1):
  if i%2 == 0:
    ans += fctr[n-i]*dp[nn][i]
  else:
    ans -= fctr[n-i]*dp[nn][i]
  ans %= mod
print(ans)
### BUGGY CODE ###

A,B,C,X,Y = map(int,input().split())
ans = 100000000000000000000000000000000000000
for c in range (max(2*X,2**Y)):
  price = A*max(0,X-(0.5*c))+B*max(0,Y-(0.5*c))+C*c
  if price < ans:
    ans = price
print(int(ans))

### FIXED CODE ###

A,B,C,X,Y = map(int,input().split())
ans = 100000000000000000000000000000000000000
for c in range (0,100001):
  price = A*max(0,X-c)+B*max(0,Y-c)+C*2*c
  if price < ans:
    ans = price
print(int(ans))
### BUGGY CODE ###

N,M,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
 
ans = 0

sums_B = ["" for _ in range(len(B)+1)]

for b in range(len(B)+1):
    sums_B[b] = sum(B[:b])
    
for a in range(len(A)+1):
  sums_A = sum(A[:a])
  if K - sums_A >= 0:
    b_max = max([k for k, v in enumerate(sums_B) if v <= K-sums_A])
    if ans < a+b_max:
        ans = a+b_max
  else:
    break
print(ans)

### FIXED CODE ###

import sys
import math
import itertools
import collections
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()

NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()

def main():
    N, M, K = NMI()
    A = NLI()
    B = NLI()
    
    cumsum_A = [0 for _ in range(len(A)+1)]
    cumsum_B = [0 for _ in range(len(B)+1)]    
    
    cnt = 0
    
    for n in range(N):
        cnt += A[n]
        cumsum_A[n+1] = cnt
        
    cnt = 0
    
    for m in range(M):
        cnt += B[m]
        cumsum_B[m+1] = cnt
    

    
    ans = 0
    b= M
    
    for n in range(N+1):
        remain_K = K - cumsum_A[n]
        if remain_K < 0:
            break
        else:
            for m in range(b,-1,-1):
                if cumsum_B[m]> remain_K:
                    continue
                else:
                    b = m
                    ans = max(ans,n+m)
                break
    
    print(ans)
            
    


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

# ABC093B
a,b,k = map(int,input().split())
for x in range(a,b+1):
    if x<a+k or x>b-k:
        print(x)

### FIXED CODE ###

# ABC093B
a,b,k = map(int,input().split())
xx =[]
for x in range(a,a+k):
    if x>b:
        break
    xx.append(x)
for x in range(b+1-k,b+1):
    if x<a:
        break
    xx.append(x)
for x in sorted(list(set(xx))):
    print(x)
### BUGGY CODE ###

from collections import Counter
s=input()
m=len(s)
DP=[0]

for i in range(m):
    DP.append(int(s[m-(i+1):]))

for i in range(len(DP)):
    DP[i]=DP[i]%2019
DP=Counter(DP)

ans=0
for v,m in DP.items():
    if m>=2:ans +=m*(m-1)//2
print(ans)

### FIXED CODE ###

from collections import Counter
s=input()[::-1]
DP=[0]

num,point=0,1
for i in s:
    num +=int(i)*point
    num %=2019
    DP.append(num)
    point *=10
    point %=2019

ans=0
DP=Counter(DP)
for v,m in DP.items():
    if m>=2:
        ans +=m*(m-1)//2
print(ans)
### BUGGY CODE ###

"""import sys
input = sys.stdin.readline
n,m=map(int,input().split())
A=list(map(int,input().split()))
if n==1:
    ans=(m//(A[0]//2)+1)//2
    print(int(ans))
    exit()
from fractions import gcd
kou=A[0]*A[1]//gcd(A[0],A[1])
for a in A:
    kou=a*kou//gcd(a,kou)
for a in A:
    if (kou//a)%2==0:
        print(0)
        exit()
kou//=2
#print(kou)
ans=(m//kou+1)//2
print(int(ans))"""
def main():
    """"ここに今までのコード"""
    import sys
    input = sys.stdin.readline
    n,m=map(int,input().split())
    A=list(map(int,input().split()))
    if n==1:
        ans=(m//(A[0]//2)+1)//2
        print(int(ans))
        exit()
    from fractions import gcd
    kou=A[0]*A[1]//gcd(A[0],A[1])
    for a in A:
        kou=a*kou//gcd(a,kou)
    for a in A:
        if (kou//a)%2==0:
            print(0)
            exit()
    kou//=2
    #print(kou)
    ans=(m//kou+1)//2
    print(int(ans))
if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    """"ここに今までのコード"""
    import sys
    input = sys.stdin.readline
    n,m=map(int,input().split())
    A=list(map(int,input().split()))
    #A.sort()
    if n==1:
        ans=(m//(A[0]//2)+1)//2
        print(int(ans))
        exit()
    from fractions import gcd
    kou=A[0]*A[1]//gcd(A[0],A[1])
    for a in A:
        kou=a*kou//gcd(a,kou)
        if (kou//a)%2==0:
            print(0)
            exit()
    kou//=2
    #print(kou)
    ans=(m//kou+1)//2
    print(int(ans))
if __name__ == '__main__':
    main()
### BUGGY CODE ###

from fractions import gcd
n, x =map(int,input().split())
s = list(map(int,input().split()))
s.sort()
a, b = x - s[0], s[-1] - x
visit = [0] * n
while sum(visit) != n:
    visit = [0] * n
    y = gcd(a, b)
    i = 0
    while s[0] + y * i <= s[-1] :
        if s[0] + y * i in s:
            visit[s.index(s[0] + y * i)] = 1
        i += 1
    a,b = min(a, b), y
print(y)



### FIXED CODE ###

from fractions import gcd
n, x =map(int,input().split())
s = list(map(int,input().split()))
y = abs(s[0] - x)
for i in range(1,n):
    y = gcd(y, abs(s[i] - x))
print(y)
### BUGGY CODE ###

n, m, q = map(int, input().split())
x = [tuple(map(int, input().split())) for _ in range(m)]
y = [tuple(map(int, input().split())) for _ in range(q)]

table = [[0]*n for _ in range(n)]

for i, j in x:
    table[i-1][j-1] += 1

s = [[table[i][0]] for i in range(n)]

for i in range(n):
    for j in range(1, n):
        s[i].append(s[i][-1]+table[i][j])

for i, j in y:
    tmp = 0
    if i == 1:
        for k in range(i-1, j):
            tmp += s[k][j-1]
    else:
        for k in range(i-1, j):
            tmp += s[k][j-1] - s[k][i-2]
    print(tmp)



'''
for i in range(n):
    for j in range(1, n):
        table[i][j] += table[i][j-1]

for i in range(n-1, 0, -1):
    for j in range(n):
        table[i-1][j] += table[i][j]

for i, j in y:
    print(table[i-1][j-1])
'''


### FIXED CODE ###

n, m, q = map(int, input().split())
x = [tuple(map(int, input().split())) for _ in range(m)]
y = [tuple(map(int, input().split())) for _ in range(q)]

table = [[0]*n for _ in range(n)]

for i, j in x:
    table[i-1][j-1] += 1

for i in range(n):
    for j in range(1, n):
        table[i][j] += table[i][j-1]

for i in range(n-1, 0, -1):
    for j in range(n):
        table[i-1][j] += table[i][j]

for i, j in y:
    print(table[i-1][j-1])
### BUGGY CODE ###

H,W,M = map(int,input().split())
X = [0 for i in range(H)]
Y = [0 for j in range(W)]
combi = []
for k in range(M):
    pos = list(map(int,input().split()))
    X[pos[0]-1]+=1
    Y[pos[1]-1]+=1
    combi.append(pos)
a = max(X)
b = max(Y)
X_max = []
Y_max = []
for l in range(H):
    if X[l] == a:
        X_max.append(l+1)
for m in range(W):
    if Y[m] == b:
        Y_max.append(m+1)
flg = 1
for p in X_max:
    for q in Y_max:
        ls = [p,q]
        if not ls in combi:
            flg = 0
            break
print(a + b - flg)

### FIXED CODE ###

H,W,M = map(int,input().split())
X = [0 for i in range(H)]
Y = [0 for j in range(W)]
combi = []
for k in range(M):
    pos = list(map(int,input().split()))
    X[pos[0]-1]+=1
    Y[pos[1]-1]+=1
    combi.append(1000000007*pos[0]+pos[1])
a = max(X)
b = max(Y)
X_max = [0 for d in range(H)]
Y_max = [0 for e in range(W)]
for l in range(H):
    if X[l] == a:
        X_max[l]+=1
for m in range(W):
    if Y[m] == b:
        Y_max[m]+=1
X_count = X_max.count(1)
Y_count = Y_max.count(1)
chance = X_count*Y_count
flg = 1
for s in combi:
    ans1 = s//1000000007
    ans2 = s % 1000000007
    if X_max[ans1-1]==1 and Y_max[ans2-1]==1:
        chance-=1
if chance > 0:
    flg = 0
print(a + b - flg)
### BUGGY CODE ###

N = int(input())
A = tuple(map(int,input().split()))
B = list(A)
O = []

for i in range(N):
    n = 0
    a = min(B)
    for n in range(len(A)):
        if A[n] == a:
            O.append(n+1)
            B.remove(min(B))

S = ''
for j in range(N):
    S += str(O[j]) + ' '

print(S.lstrip(' '))

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
O = [0] * N

for i , a  in enumerate(A): #リストAのインデックスiと値a
    O[a-1] = i+1

print(*O)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

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

pl = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    pl[p-1] += x


def dfs(curr, pare):
    for chi in g[curr]:
        if chi == pare: continue
        pl[chi] += pl[curr]
        dfs(chi, curr)

def main():
    dfs(0,-1)
    print(*pl)

if __name__ == "__main__":
    main()

### FIXED CODE ###

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

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

pl = [0] * n
for _ in range(q):
    p, x = map(int, input().split())
    pl[p-1] += x


def dfs(curr, pare):
    for chi in g[curr]:
        if chi == pare: continue
        pl[chi] += pl[curr]
        dfs(chi, curr)

def main():
    dfs(0,-1)
    print(*pl)

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

N = int(input())  # N<= 4000 6*10^10なので、削減しないとだめ
S = list(input())


# Si Sj Skがどれも別のもの。ただしi<j<k
# また、j-i != k-j
# 1,2,3はだめ1,2,4はok
# 1,3,5もだめ
# この組の数を求める

# count = 0
# for i in range(N):
#     for j in range(i + 1, N):
#         for k in range(j + 1, N):
#             if j - i != k - j:
#                 if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
#                     count += 1


permutation_hash = {'R': [], 'G': [], 'B': []}
for i, char in enumerate(S):
    permutation_hash[char].append(i + 1)
# print(permutation_hash)
count = 0
for R_index in permutation_hash['R']:
    for G_index in permutation_hash['G']:
        for B_index in permutation_hash["B"]:
            indexes = [R_index, G_index, B_index]
            indexes.sort()
            if (indexes[2] - indexes[1]) != (indexes[1] - indexes[0]):
                count += 1
print(count)


### FIXED CODE ###

N = int(input())
S = input()
r = 0
g = 0
b = 0
for i in range(N):
    if S[i] == "R":
        r += 1
    elif S[i] == "G":
        g += 1
    else:
        b += 1
ans = r * g * b

for i in range(N - 2):
    for j in range(i + 1, N - 1):
        x = j + j - i
        if S[i] != S[j] and x <= N - 1:
            if S[i] != S[x] and S[x] != S[j]:
                ans -= 1

print(ans)