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

n,k=map(int,input().split())
p=list(map(int,input().split()))
sum1=0
max1=0
for i in range(n-k+1):
    sum1=0
    max1=max1
    for j in range(i,i+k):
        sum1=sum1+((1+p[j])/2)
    if sum1>max1:
      max1=sum1
print(max1)



### FIXED CODE ###

n,k=map(int,input().split())
p=list(map(int,input().split()))
sum1=0
a=[]
for j in range(k):
    sum1=sum1+((1+p[j])/2)
a.append(sum1)
for i in range(1,n-k+1):
    sum1=sum1-((1+p[i-1])/2)+((1+p[i+k-1])/2)
    a.append(sum1)
ans=max(a)
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())

def main():
    N, M, P = mis()
    
    to = [[] for _ in range(N)]
    ot = [[] for _ in range(N)]
    edges = []

    for i in range(M):
        a,b,c = mis()
        a -= 1
        b -= 1
        c = -(c-P)
        #
        to[a].append(b)
        ot[b].append(a)
        edges.append((a,b,c))

    reachableFrom0 = set()
    reachableToN = set()

    # dfs
    reachableFrom0.add(0)
    nodes = [0]
    while nodes:
        node = nodes.pop()
        for i in to[node]:
            if i not in reachableFrom0:
                nodes.append(i)
                reachableFrom0.add(i)

    #rdfs
    reachableToN.add(N-1)
    nodes = [N-1]
    while nodes:
        node = nodes.pop()
        for i in ot[node]:
            if i not in reachableToN:
                nodes.append(i)
                reachableToN.add(i)


    ok = reachableFrom0 & reachableToN

    edges = tuple((a, b, c) for a, b, c in edges if a in ok and b in ok)

    V = [float('inf')] * N
    V[0] = 0

    def bf(n):
        for _ in range(n):
            for a, b, c in edges:
                V[b] = min(V[b], V[a] + c)

    bf(N)

    Vb = tuple(V)
    bf(1)

    if tuple(V) == Vb:
        print(max(-V[-1], 0))
    else:
        print(-1)

main()


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())

def main():
    N, M, P = mis()
    
    to = [[] for _ in range(N)]
    ot = [[] for _ in range(N)]
    edges = []

    for i in range(M):
        a,b,c = mis()
        a -= 1
        b -= 1
        c = -(c-P)
        #
        to[a].append(b)
        ot[b].append(a)
        edges.append((a,b,c))

    reachableFrom0 = set()
    reachableToN = set()

    # dfs
    reachableFrom0.add(0)
    nodes = [0]
    while nodes:
        node = nodes.pop()
        for i in to[node]:
            if i not in reachableFrom0:
                nodes.append(i)
                reachableFrom0.add(i)

    #rdfs
    reachableToN.add(N-1)
    nodes = [N-1]
    while nodes:
        node = nodes.pop()
        for i in ot[node]:
            if i not in reachableToN:
                nodes.append(i)
                reachableToN.add(i)


    ok = reachableFrom0 & reachableToN

    edges = tuple((a, b, c) for a, b, c in edges if a in ok and b in ok)

    V = [float('inf')] * N
    V[0] = 0

    def bf(n):
        for _ in range(n):
            upd = False
            for a, b, c in edges:
                if V[b] > V[a] + c:
                    V[b] = V[a] + c
                    upd = True
            if not upd:
                return False
        return True

    bf(N)

    if not bf(1):
        print(max(-V[-1], 0))
    else:
        print(-1)

main()
### BUGGY CODE ###

n, m = map(int, input().split())
li = []
for i in range(m):
  li.append(list(input().split()))
a = []
b = 0
for j in range(m):
  if li[j][1] == "AC" and li[j][0] not in a:
    a.append(li[j][0])
  elif li[j][1] == "WA" and li[j][0] not in a:
    b += 1
for k in range(m):
  if li[k][0] not in a:
    b -= 1
print(len(a), b)

### FIXED CODE ###

n, m = map(int, input().split())
li = []
for i in range(m):
  li.append(list(input().split()))
li_a = [0 for i in range(n)]
li_b = [0 for i in range(n)]
a = 0
b = 0
for j in range(m):
  if li[j][1] == "WA":
    li_b[int(li[j][0])-1] += 1
  elif li[j][1] == "AC" and li_a[int(li[j][0])-1] == 0:
    a += 1
    b += li_b[int(li[j][0])-1]
    li_a[int(li[j][0])-1] += 1
print(a, b)
### BUGGY CODE ###

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

### FIXED CODE ###

A, B, K = map(int, input().split())
for i in range(A, min(A+K, B+1)):
    print(i)
for i in range(max(B-K+1, A+K), B+1):
    print(i)
### BUGGY CODE ###

n = int(input())
a = [int(x) for x in input().split()]

ans = 1
for i in range(n):
    ans = ans * a[i]

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


### FIXED CODE ###

n = int(input())
a = [int(x) for x in input().split()]

if a.count(0) > 0:
    print(0)
    exit()

ans = 1

for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()


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

k = int(input())

import math



d=0
s = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            d = math.gcd(a,b)
            s+=math.gcd(d,c)

            d=0
print(s)

### FIXED CODE ###

k = int(input())

import math
d=0
e=0
f=0
s = 0
ss=0
sss=0
for a in range(1,k+1):
    for b in range(1,k+1):
        e+=1
        d = math.gcd(a,b)

        for c in range(e,k+1):
#            print(a,b,c)                                                      
            if f==0:
                ss+=math.gcd(d,c)
#                print(a,b,c)                                                  
                f+=1
            else:
                s+=math.gcd(d,c)

        d=0
        s *=2
        s+=ss
        sss+=s
        s=0
        ss=0
        f=0
    e=0
print(sss)
### BUGGY CODE ###

from collections import deque
import numpy as np
N = int(input())
A = [int(input()) for _ in range(N)]

# d = deque()
R = deque(A)
R.append(0)
L = deque([0])

for i in A:
  R.popleft()
  print(max(np.max(L), np.max(R)))
  L.append(i)
  

### FIXED CODE ###

N = int(input())
A = [int(input()) for _ in range(N)]
B = A[:]
B.sort(reverse=True)
# print(A)
fmax = B[0]
smax = B[1]
for i in A:
  if i == fmax:
    print(smax)
  else:
    print(fmax)
### BUGGY CODE ###

from collections import defaultdict

N, M = map(int, input().split())
path = defaultdict(list)

for i in range(M):
    A, B = map(int, input().split())
    path[A].append(B)
    path[B].append(A)

ans = [0] * (N + 1)
ans[1] = 1
dst = [1]

while True:
    if len(dst) == 0:break
    tmp = []
    for d in dst:
        for a in path[d]:
            if ans[a] == 0:
                ans[a] = d
                for b in path[a]:
                    if ans[b] == 0:
                        tmp.append(a)

    dst = tmp

for a in ans[2:]:
    if a == 0:
        print('No')
        exit()

print('Yes')
for a in ans[2:]:
    print(a)


### FIXED CODE ###

from collections import defaultdict, deque

N, M = map(int, input().split())
path = defaultdict(list)

for i in range(M):
    A, B = map(int, input().split())
    A -= 1
    B -= 1
    path[A].append(B)
    path[B].append(A)

prev = [0] * N
dist = [0] * N
q = deque([0])

while (len(q) > 0):
    a = q.popleft()
    for b in path[a]:
        if dist[b] != 0:continue
        q.append(b)
        prev[b] = a
        dist[b] = dist[a] + 1

print('Yes')

for a in prev[1:]:
    a += 1
    print(a)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))
f = 0
m = 10**6 + 10
t = [0] * (10**6 + 10)

def bunkai(n):
    global f
    if n % 2 == 0 and t[2] == 0:
        t[2] = 1
    elif n % 2 == 0 and t[2] == 1:
        f = 1
        return
    while n % 2 == 0:
        n //= 2
    l = 3
    while l * l < n:
        if n % l == 0:
            if t[l] == 1:
                f = 1
                return
            while n % l == 0:
                n //= l
        l += 2
    if n != 1:
        if t[n] == 1:
            f = 1
        else:
            t[n] = 1

for i in range(N):
    bunkai(A[i])
    if f == 1:
        break

from math import gcd
g = A[0]
if f == 1:
    for i in range(1, N):
        g = gcd(g, A[i])
        if g == 1:
            break

if f == 0:
    print("pairwise coprime")
elif g == 1 and f == 1:
    print("setwise coprime")
else:
    print("not coprime")

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
f = 0
m = 10**6 + 10
t = [0] * (10**6 + 10)

def bunkai(n):
    global f
    if n % 2 == 0 and t[2] == 0:
        t[2] = 1
    elif n % 2 == 0 and t[2] == 1:
        f = 1
        return
    while n % 2 == 0:
        n //= 2
    l = 3
    while l * l < n:
        if n % l == 0:
            if t[l] == 1:
                f = 1
                return
            while n % l == 0:
                n //= l
        l += 2
    if n != 1:
        if t[n] == 1:
            f = 1
        else:
            t[n] = 1

for i in range(N):
    bunkai(A[i])
    if f == 1:
        break

from math import gcd
g = A[0]
if f == 1:
    for i in range(1, N):
        g = gcd(g, A[i])
        if g == 1:
            break

if f == 0:
    print("pairwise coprime")
elif g == 1 and f == 1:
    print("setwise coprime")
else:
    print("not coprime")
### BUGGY CODE ###

import sys
def main():
  input=sys.stdin.readline
  h,w=map(int,input().split())
  a=[list(map(int,input().split())) for _ in range(h)]
  b=[list(map(int,input().split())) for _ in range(h)]
  m=80*(h+w)
  dp=[[[False]*(m+1) for i in range(w)] for j in range(h)]
  dp[0][0][abs(a[0][0]-b[0][0])]=True
  for i in range(h):
    for j in range(w):
      for k in range(m+1):
        if dp[i][j][k]:
          if i<h-1:
            if abs(k+a[i+1][j]-b[i+1][j])<=m:
              dp[i+1][j][abs(k+a[i+1][j]-b[i+1][j])]=True
            if abs(k+b[i+1][j]-a[i+1][j])<=m:
              dp[i+1][j][abs(k+b[i+1][j]-a[i+1][j])]=True
          if j<w-1:
            if abs(k+a[i][j+1]-b[i][j+1])<=m:
              dp[i][j+1][abs(k+a[i][j+1]-b[i][j+1])]=True
            if abs(k+b[i][j+1]-a[i][j+1])<=m:
              dp[i][j+1][abs(k+b[i][j+1]-a[i][j+1])]=True
  for i in range(m+1):
    if dp[h-1][w-1][i]:
      return print(i)
if __name__=='__main__':
  main()

### FIXED CODE ###

import sys
def main():
  input=sys.stdin.readline
  h,w=map(int,input().split())
  a=[list(map(int,input().split())) for _ in range(h)]
  b=[list(map(int,input().split())) for _ in range(h)]
  m=80*162
  flg=(1<<(m*2))-1
  dp=[[0]*w for j in range(h)]
  dp[0][0]|=1<<(a[0][0]-b[0][0]+m)
  dp[0][0]|=1<<(b[0][0]-a[0][0]+m)
  for i in range(h):
    for j in range(w):
      if i<h-1:
        ne=abs(a[i+1][j]-b[i+1][j])
        dp[i+1][j]|=(dp[i][j]<<ne)&flg
        dp[i+1][j]|=(dp[i][j]>>ne)&flg
      if j<w-1:
        ne=abs(a[i][j+1]-b[i][j+1])
        dp[i][j+1]|=(dp[i][j]<<ne)&flg
        dp[i][j+1]|=(dp[i][j]>>ne)&flg
  ans=10**10
  for i in range(160*162):
    if (dp[h-1][w-1]>>i)&1:
      ans=min(ans,abs(i-m)) 
  return print(ans)
if __name__=='__main__':
  main()
### BUGGY CODE ###

def resolve():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    ans = 0
    l = []
    for i in range(K):
        l.append((p[i]*(p[i]+1))//2/p[i])
    ans = sum(l)
    for i in range(K, N):
        l.append((p[i]*(p[i]+1))//2/p[i])
        tmp = sum(l[-K:])
        if ans < tmp:
            ans = tmp
    print(ans)
resolve()

### FIXED CODE ###

def resolve():
    N, K = map(int, input().split())
    p = list(map(int, input().split()))
    l = [0]*N
    l[0] = p[0]+1
    for i in range(1, N):
        l[i] = l[i-1]+p[i]+1
    ans = l[K-1]
    for i in range(N-K):
        tmp = l[K+i]-l[i]
        if tmp > ans:
            ans = tmp
    print(ans/2)
resolve()
### BUGGY CODE ###

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

for i in range(Q):
	count = 0
	l, r = map(int, input().split())
	Sr = S[l-1:r]
	j = 0
	while (j < (len(Sr)-1)):
		if(Sr[j] == 'A' and Sr[j+1] == 'C'):
			count += 1
			j += 1
		elif(Sr[j+1] != 'A'):
			j += 1
		j += 1
	print(count)
	

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = [0]*(N+1)
for i in range(N):
	t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

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

import sys

sys.setrecursionlimit(10**7)

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N = in_n()
    A = in_nl()

    n1 = A.count(1)
    n2 = A.count(2)
    n3 = A.count(3)

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

    def solve(n1, n2, n3):

        if dp[n1][n2][n3] != -1:
            return dp[n1][n2][n3]

        cnt = n1 + n2 + n3
        ret = 0
        if n3 >= 1:
            ret += solve(n1, n2 + 1, n3 - 1) * n3
        if n2 >= 1:
            ret += solve(n1 + 1, n2 - 1, n3) * n2
        if n1 >= 1:
            ret += solve(n1 - 1, n2, n3) * n1

        ret = (ret + N) / cnt
        dp[n1][n2][n3] = ret
        return ret

    print(solve(n1, n2, n3))


if __name__ == '__main__':
    main()


### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
num1,num2,num3=0,0,0
for i in range(n):
    if a[i]==1:
        num1+=1
    elif a[i]==2:
        num2+=1
    else:
        num3+=1
dp=[[[-1.0 for k in range(n+1)] for i in range(n+1)] for j in range(n+1)]
def f(n1,n2,n3):
    if dp[n1][n2][n3]>=0.0:
        return dp[n1][n2][n3]
    if n1==n2==n3==0:
        return 0.0
    ret=n
    if n1>0:
        ret+=f(n1-1,n2,n3)*n1
    if n2>0:
        ret+=f(n1+1,n2-1,n3)*n2
    if n3>0:
        ret+=f(n1,n2+1,n3-1)*n3
    ret*=1.0/(n1+n2+n3)
    dp[n1][n2][n3]=ret
    return dp[n1][n2][n3]
print(f(num1,num2,num3))
### BUGGY CODE ###

import sys
from collections import defaultdict
sys.setrecursionlimit(10 ** 9)
# 深さ優先探索
def dfs(x, seen):
  seen.add(x)
  for i in G[x]:
    if i in seen:
      continue
    dfs(i, seen)

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

# Graph構造を作らないといけない。
S = set()
G = defaultdict(list)
for _ in range(M):
  A, B = map(int, input().split())
  G[A-1].append(B-1)
  G[B-1].append(A-1)
  S |= set([A-1, B-1])

n_iter = 0
R = defaultdict(set)
while len(S) != 0:
    seen = set()
    dfs(S.pop(), seen)
    R[n_iter] = seen
    S = S - seen
    n_iter += 1

Block = defaultdict(set)
for _ in range(K):
  C, D = map(int, input().split())
  Block[C-1] |= set([D-1])
  Block[D-1] |= set([C-1])

seq = [0]*N

for i in range(n_iter):
    r = R[i]
    for j in r:
        seq[j] = len(r) - len(G[j]) - len(r&Block[j]) - 1

print(*seq)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 9)

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

Friend = [[] for i in range(N)]
for _ in range(M):
  A, B = map(int, input().split())
  Friend[A-1].append(B-1)
  Friend[B-1].append(A-1)

Block = [set() for i in range(N)]
for _ in range(K):
  C, D = map(int, input().split())
  Block[C-1].add(D-1)
  Block[D-1].add(C-1)


def dfs(x):
    if seen[x] == 0:
        R[cnt].add(x)
        seen[x]=1
        for i in Friend[x]:
            dfs(i)

seen = [0]*N
cnt  = 0
R    = []
for i in range(N):
    if seen[i] == 0:
        R.append(set())
        dfs(i)
        cnt += 1

seq = [0]*N

for r in R:
    lr = len(r)
    for j in r:
        seq[j] = lr - len(Friend[j]) - len(r&Block[j]) - 1

print(*seq)
### BUGGY CODE ###

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

count = 0
for a in range(n):
    for b in range(a+1,n):
        diff = b-a
        height_sum = alist[b]+alist[a]
        if diff == height_sum:
            count+=1
print(count)

### FIXED CODE ###

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

a_dict = dict()
b_dict = dict()

for i in range(n):
    a = h_list[i]+i
    b = i-h_list[i]
    if not a in a_dict:
        a_dict[a] = 1
    else:
        a_dict[a] += 1
    if not b in b_dict:
        b_dict[b] = 1
    else:
        b_dict[b] += 1

count = 0
for a in a_dict:
    if a in b_dict:
        count += a_dict[a]*b_dict[a]
print(count)
### BUGGY CODE ###

d, g = [int(i) for i in input().split()]
p = []
c = []
for i in range(d):
    x, y = [int(_) for _ in input().split()]
    p.append(x)
    c.append(y)

ans = 100 * 10
for i in range(1, 100**d):
    score = 0
    cnt = 0
    pat = [0 for i in range(d)]
    for j in range(d):
        pat[j] = i % 100
        i = i//100
    for j in range(d):
        if pat[j] >= p[j]:
            score += p[j] * (j+1) * 100 + c[j]
            cnt += p[j]
        else:
            score += pat[j] * (j+1) * 100
            cnt += pat[j]
    if score >= g and cnt < ans:
        ans = cnt
print(ans)

### FIXED CODE ###

import math
# N = int(input())
D, G = [int(i) for i in input().split()]
problems = []
for i in range(D):
    p, c = [int(_) for _ in input().split()]
    bit = 0
    problems.append([p, c])

ans = 1001
for i in range(2**D):
    score = 0
    p_num = 0
    for j, p in enumerate(problems):
        if i >> j & 1:
            score += p[0] * 100 * (j + 1) + p[1]
            p_num += p[0]
    if score < G:
        rest = G - score
        for j in range(D-1, -1, -1):
            if i >> j & 1:
                continue
            n = math.ceil(rest / (100 * (j + 1)))
            if n <= problems[j][0] - 1:
                rest -= n * 100 * (j + 1)
                p_num += n
                break
            rest -= problems[j][0] * 100 * (j + 1)
            p_num += problems[j][0]
        if rest <= 0:
            ans = min(ans, p_num)
    else:
        ans = min(ans, p_num)
print(ans)
### BUGGY CODE ###

n, x = map(int, input().split())
def burger(x):
  if x == 0:
    return "P"
  else:
    return "B" + burger(x-1) + "P" + burger(x-1) + "B"
print(burger(n)[:x].count("P"))

### FIXED CODE ###

n, x = map(int, input().split())
L = [1] * n
P_num = [1] * n

for i in range(n-1):
  L[i + 1] = L[i] * 2 + 3
  P_num[i + 1] = P_num[i] * 2 + 1

def pati_num(n, x):
  if n == 0:
    if x >= 1:
      return 1
    else:
      return 0
  elif x <= 1 + L[n-1]:
    return pati_num(n-1, x-1)
  else:
    return P_num[n-1] + 1 + pati_num(n-1, x-2-L[n-1])
print(pati_num(n, x))
### BUGGY CODE ###

import copy
N = int(input())
S = input()
ans = 0
R = []
G = []
B = []
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
    R.append(r)
    G.append(g)
    B.append(b)

for i in range(N-3):
    for k in range(i+3, N):
        if S[i] != S[k]:
            L = "RGB"
            L = L.replace(S[i],"",1)
            L = L.replace(S[k],"",1)
            if L == "R":
                ans += R[k]-R[i]
            if L == "G":
                ans += G[k]-G[i]
            if L == "B":
                ans += B[k]-B[i]
            if (k-i) % 2 == 0:
                if S[int((k-i)/2 + i)] == L:
                    ans -= 1


print(ans)

### FIXED CODE ###

import copy
N = int(input())
S = input()

R = set()
G = set()
B = set()

for i in range(N):
    if S[i] == "R":
        R.add(i)
    elif S[i] == "G":
        G.add(i)
    else:
        B.add(i)

ans = len(R)*len(G)*len(B)

for r in R:
    for g in G:
        L = g - r
        if g + L in B:
            ans -= 1
        if r - L in B:
            ans -= 1
        if L % 2 == 0 and L//2 + r in B:
            ans -= 1
            



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

#abc177_C_4_掛け算の時点で計算を挟む、最後のあまりは最後の時に
int_n = int(input())
list_tmp = list(map(int, input().split()))
 
int_sum = 0
int_divide = (10**9) + 7
 
for i in range(0, len(list_tmp) - 1):
  for j in range(i + 1, len(list_tmp)):
    int_sum = (int_sum + ((list_tmp[i]%int_divide) * (list_tmp[j]%int_divide)))
    
int_sum = int_sum%int_divide
print(int_sum)

### FIXED CODE ###

#abc177_C_6_retry_累積和を使用する
int_n = int(input())
list_tmp = list(map(int, input().split()))
 
int_sum = 0
int_divide = (10**9) + 7
int_sum_tmp = sum(list_tmp)

for i in range(0, len(list_tmp) - 1):
  int_sum_tmp = int_sum_tmp - list_tmp[i]
  int_sum = int_sum + (int_sum_tmp * list_tmp[i])
print(int_sum % int_divide)
#  for j in range(i + 1, len(list_tmp)):
#    if list_tmp[i] >= int_divide:
#      list_tmp_i = list_tmp[i]%int_divide
#    else:
#      list_tmp_i = list_tmp[i]
#      
#    if list_tmp[j] >= int_divide:
#      list_tmp_j = list_tmp[j]%int_divide
#    else:
#      list_tmp_j = list_tmp[j]    
#    
#    int_sum = int_sum + (list_tmp_i*list_tmp_j)
#    
#    if int_sum >= int_divide:
#      int_sum = int_sum%int_divide
#      
#print(int_sum)
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()
cnt = 0

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

print(cnt)

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()
S = list(input())
 
r = S.count("R")
g = S.count("G")
b = S.count("B")
 
 
A = list(range(len(S)))
cnt = 0
for x, y in combinations(A, 2):
	if (x+y)//2 == (x+y)/2:
		z = (x+y)//2
		if S[x] != S[y] and S[x] != S[z] and S[y] != S[z]:
			cnt += 1
 
print(r*g*b-cnt)
### BUGGY CODE ###

K=int(input())
S=0
import math
for i in range(1,K+1):
  for j in range(1,K+1):
    for k in range(1,K+1):
      S+=math.gcd(i,math.gcd(j,k))
print(S)

### FIXED CODE ###

K=int(input())
def gcd(p,q):
    if p%q==0:
        return q
    return gcd(q,p%q)
S=0
for i in range(K):
    for j in range(K):
        for k in range(K):
            S+=gcd(i+1,gcd(j+1,k+1))
print(S)
### BUGGY CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

import numpy as np

def canReach(src, dst):
    dist = np.sum(np.abs(src-dst)[1:3])
    time = (dst[0] - src[0])
    if time - dist >= 0 and (time - dist) % 2 == 0:
        return True
    return False

N = int(input())
dst = np.array([[int(x) for x in input().split(" ")] for z in range(N)])

available = True
pos = [0, 0, 0]

for n in range(N):
    if not canReach(pos, dst[n]):
        available = False
        break
    else:
        pos = dst[n]

if available:
    print("Yes")
else:
    print("No")



### FIXED CODE ###

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import numpy as np

N = int(input())
prev_dst = [0,0,0]

for n in range(N):
    t, x, y = map(int, input().split(" "))
    a = (t - prev_dst[0]) - (np.abs(prev_dst[1]-x) + np.abs(prev_dst[2]-y))
    if a >= 0 and a % 2 == 0:
        prev_dst = [t, x, y]
    else:
        print("No")
        exit(0)

print("Yes")