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

li = list(input())
count = 0

i = 0
while(i<len(li)-2):
  if(li[i]=='A' and li[i+1]=='B' and li[i+2]=='C'):
    count += 1
    li[i]='B'
    li[i+1]='C'
    li[i+2]='A'
    if(i!=0 and li[i-1]=='A'):
      i = i-1
    else:
      i = i+2
  else:
    i = i+1

print(count)



### FIXED CODE ###

li = list(input())
count = 0



counta = 0
i = 0
while(i<len(li)-2):
  # print(i, counta, count)
  if(li[i]=='A'):
    counta += 1
    # print(i)
    if(li[i+1]=='B' and li[i+2]=='C'):
      count += counta
      li[i]='B'
      li[i+1]='C'
      li[i+2]='A'
      i = i+2
      counta -=1
    else:
      i += 1
  else:
    counta = 0
    i = i+1

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

N, M, Q = [int(_) for _ in input().split()]
train = [[]] * M
question = [[]] * Q
for i in range(M):
    train[i] = [int(_) for _ in input().split()]
for i in range(Q):
    question[i] = [int(_) for _ in input().split()]

l = [[0 for i in range(N)] for j in range(N)]
for i in range(N):
    s = 0
    for j in range(N):
        if i >= j:
            a = train.count([j+1, i+1])
        else:
            a = train.count([i+1, j+1])
        l[i][j] = s + a
        s += a

for k in range(Q):
    p = question[k][0]
    q = question[k][1]
    ans = 0
    for i in range(p-1, q):
        if i == 0:
            d = l[i][q-1]
        else:
            d = l[i][q-1] - l[i][i-1]
        ans += d
    print(ans)



### FIXED CODE ###

N, M, Q = [int(_) for _ in input().split()]

l = [[0 for i in range(N+1)] for j in range(N+2)]
for t in [input().split() for _ in range(M)]:
    i = int(t[0])
    j = int(t[1])
    l[i][j] += 1

for k in range(N):
    for i in range(1, N-k+1):
        j = i + k
        l[i][j] += l[i][j-1] + l[i+1][j] - l[i+1][j-1]

for k in [input().split() for _ in range(Q)]:
    p = int(k[0])
    q = int(k[1])
    print(l[p][q])
### BUGGY CODE ###

L = input()
p = 10 ** 9 + 7
l = len(L)
ones = 0
cnt = 1
for i, b in enumerate(L):
  if b == '1':
    left = 2 ** ones % p
    right = (3 ** (l - 1 - i) + 1) % p
    cnt += left * right
    cnt %= p
    ones += 1
print(cnt)

### FIXED CODE ###

L = input()
p = 10 ** 9 + 7
l = len(L)
ones = 0
cnt = 1
two = [1] * l
three = [1] * l
for i in range(1, l):
  two[i] = two[i - 1] * 2 % p
  three[i] = three[i - 1] * 3 % p
for i, b in enumerate(L):
  if b == '1':
    left = two[ones]
    right = (three[l - 1 - i] + 1) % p
    cnt += left * right
    cnt %= p
    ones += 1
print(cnt)
### BUGGY CODE ###

n=int(input())
List=[1 for x in range(n+1)]
for x in range(2,n+1):
  for y in range(x,n+1,x):
    List[y]+=1
ans=0
for x in range(1,n+1):
  ans+=(List[x]*x)
print(ans)


### FIXED CODE ###

n=int(input())
List=[2 for x in range(n+1)]
List[0]=0
List[1]=1
ans=1

for x in range(2,n+1):
  for y in range(2*x,n+1,x):
    List[y]+=1
  ans+=x*List[x]
print(ans)
### BUGGY CODE ###

N = int(input())
P = list(map(int,input().split()))
P_min = []
ans = 0

for i in range(N):
    P_min.append(min(P[0:i+1]))

for i in range(N):
    if P_min[i] >= P[i]:
        ans += 1
        
print(ans)


### FIXED CODE ###

N = int(input())
P = list(map(int,input().split()))
P_min = []
a = 200000
ans = 0

for i in range(N):
    if a >= P[i]:
        ans += 1
        a = P[i]

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

n=int(input())
A=list(map(int,input().split()))
S=[]
for i in range(n):
    S.append([A[i],i])
S=list(reversed(sorted(S)))
#print(S)
F=[0]*n

ans=0
C=[0]*n
for i in range(n):
    s=S.pop(0)
    d=s[0] #距離
    x=s[1] #座標
    F[x]=1
    L1=max(x-2*d,0)
    L2=max(x-d,-1)
    R1=min(x+d,n)
    R2=min(x+2*d,n-1)
    if L1<=L2:
        for j in range(L1,L2+1):
            if F[j]==1:
                continue
            if x-j==d+A[j]:
                ans+=1
                #print(s,j)
    if R1<=R2:
        for j in range(R1,R2+1):
            if F[j]==1:
                continue
            if j-x==d+A[j]:
                ans+=1
                #print(s,j)
print(ans)

### FIXED CODE ###

n=int(input())
A=list(map(int,input().split()))
C=[]
for i in range(n):
    C.append([i+A[i],0])
    C.append([i-A[i],1])
C.sort()
now=C[0][0]
c0=0
c1=0
ans=0
for c in C:
    if now==c[0]:
        if c[1]==0:
            c0+=1
        else:
            c1+=1
    else:
        ans+=c0*c1
        c0=0
        c1=0
        if c[1]==0:
            c0+=1
        else:
            c1+=1
        now=c[0]
ans+=c0*c1
print(ans)
### BUGGY CODE ###

r0,g0,b0,n=map(int,input().split())
ans=0
l=[r0,g0,b0]
l.sort(reverse=True)
r=l[0]
g=l[1]
b=l[2]
x=0
while x*r<=n:
    y=0
    while y*g<=n-x*r:
        if (n-x*r-y*g) % b == 0:
            ans+=1
        y+=1
    x+=1
print(ans)

### FIXED CODE ###

r0,g0,b0,n=map(int,input().split())
ans=0
l=[r0,g0,b0]
l.sort(reverse=True)
r=l[0]
g=l[1]
b=l[2]
x=0
while x*r<=n:
    y=0
    if g==1:
        ans+=1+n-x*r
        x+=1
        continue
    if b==1:
        ans+=1+(n-x*r)//g
        x+=1
        continue
    while y*g<=n-x*r:
        if (n-x*r-y*g) % b == 0:
            ans+=1
        y+=1
    x+=1
print(ans)
### BUGGY CODE ###

def dijkstra(s,n,w,cost):
    #始点sから各頂点への最短距離
    #n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
    d = [float("inf")] * n
    used = [False] * n
    d[s] = 0
    
    while True:
        v = -1
        #まだ使われてない頂点の中から最小の距離のものを探す
        for i in range(n):
            if (not used[i]) and (v == -1):
               v = i
            elif (not used[i]) and d[i] < d[v]:
                v = i
        if v == -1:
               break
        used[v] = True
               
        for j in range(n):
               d[j] = min(d[j],d[v]+cost[v][j])
    return d

def main():
    n, x, y = map(int, input().split())
    cost = [[float("inf") for i in range(n)] for i in range(n)] 
    for i in range(n):
        if i == n - 1:
            tmp_x, tmp_y = x-1, y-1
        else:
            tmp_x, tmp_y = i, i+1
        cost[tmp_x][tmp_y] = 1
        cost[tmp_y][tmp_x] = 1

    ans_list = [0]*n

    for i in range(n):
        di_list = dijkstra(i,n,n,cost)
        for j in range(i+1,n):
            ans_list[di_list[j]] += 1

    for i in range(1,n):
        print(ans_list[i])

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    n, x, y = map(int, input().split())

    x -= 1
    y -= 1

    ans_list = [0]*n

    for i in range(n):
        for j in range(i,n):
            ans_list[min(abs(i-j), abs(i-x)+abs(j-y)+1, abs(j-x)+abs(i-y)+1)] += 1

    for i in range(1,n):
        print(ans_list[i])

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

n = int(input())
s = input()
c = s.count('R') * s.count('G') * s.count('B')
for i in range(n):
    for j in range(i + 1, n):
        if s[i] == s[j]:
            continue
        for k in range(j + 1, n):
            if s[j] == s[k] or s[k] == s[i]:
                continue
            if j - i == k - j:
                c -= 1
print(c)

### FIXED CODE ###

n = int(input())
s = input()
c = s.count('R') * s.count('G') * s.count('B')
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        k = j + (j - i)
        if k >= n:
            continue
        if s[i] == s[j] or s[j] == s[k] or s[k] == s[i]:
            continue
        c -= 1
print(c)
### BUGGY CODE ###

import bisect

n = int(input())
A = [int(input()) for i in range(n)]

Q = [A[0]] + [float("inf")] * (n+1)
le = 1
for i in range(1, n):
    if Q[le-1] >= A[i]:
        Q[le] = A[i]
        le += 1
    else:
        ind = bisect.bisect_left(Q[:le][::-1], A[i])
        Q[le-ind] = A[i]
    # print(Q[:10])

print(le)

### FIXED CODE ###

n = int(input())
A = [int(input()) for i in range(n)]

Q = [-float("inf"), A[0]] + [float("inf")] * (n+1)
le = 2
for i in range(1, n):
    if Q[le-1] >= A[i]:
        Q[le] = A[i]
        le += 1
    else:
        l = 0
        r = le
        m = (l+r)//2
        while r-l > 1:
            if Q[m] >= A[i]:
                l = m
            else:
                r = m
            m = (l+r)//2
        Q[l+1] = A[i]
    # print(Q[:10])

print(le-1)
### BUGGY CODE ###

from collections import defaultdict
import copy


mod = 10 ** 9 + 7
primes = []
for i in range(2,1002):
  for prime in primes:
    if not i % prime:
      break
  else:
    primes.append(i)

def factorize(n):
  now = n
  fct = defaultdict(int)
  for prime in primes:
    cnt = 0
    if prime ** 2 > n:
      break
    while not now % prime:
      now //= prime
      cnt += 1
    if cnt:
      fct[prime] = cnt
  if now > 1:
    fct[now] = 1
  return fct


n = int(input())
a = list(map(int, input().split()))
fct_a = list()
for i in a:
  fct_a.append(factorize(i))
lcm = defaultdict(int)
for i in fct_a:
  for k,v in i.items():
    lcm[k] = max(lcm[k], v)
ans = 0
for i in fct_a:
  b = 1
  for k,v in lcm.items():
    b *= k**(v-i[k])
    b %= mod
  ans += b
ans %= mod
print(ans)


### FIXED CODE ###

import fractions
mod = 10 ** 9 + 7

def lcm(a,b):
    return (a * b) // fractions.gcd(a, b)

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

LCM = 1
for i in a:
    LCM = lcm(LCM,i)

ans = 0
for i in a:
    ans += LCM // i
print(ans % mod)
### BUGGY CODE ###

from collections import deque

n = int(input())
a = [deque() for _ in range(n)]
cand = deque()
match = [[0 for _ in range(n)] for _ in range(n)]
for i in range(n):
    inp = list(map(int, input().split()))
    for j in range(n-1):
        a[i].append(inp[j]-1)
    e = a[i].popleft()
    mi, mj = min(i, e), max(i, e)
    cand.append([mi, mj])
    match[mi][mj] += 1

ans = 0
flag = False
while len(cand) > 0:
    ans += 1
    flag = False
    q = deque()
    nextday = []
    while len(cand) > 0:
        mi, mj = cand.pop()
        if match[mi][mj] == 2:
            cand.remove([mi, mj])
            match[mi][mj] += 1
            flag = True
            for k in [mi, mj]:
                if len(a[k]) > 0:
                    e = a[k].popleft()
                    ni, nj = min(k, e), max(k, e)
                    nextday.append([ni, nj])
        else:
            q.append([mi, mj])
    for i in range(len(nextday)):
        q.append(nextday[i])
        match[nextday[i][0]][nextday[i][1]] += 1
    if not flag:
        break
    cand = q

if flag:
    print(ans)
else:
    print(-1)

### FIXED CODE ###

n = int(input())
a = [list(map(int, input().split())) for _ in range(n)]
for i in range(n):
    for j in range(n-1):
        a[i][j] -= 1

MAXN = 1005
MAXV = MAXN*(MAXN-1)//2

to = [[] for _ in range(MAXV)]
# 頂点番号
id = [[0 for _ in range(MAXN)] for _ in range(MAXN)]
def toID(i, j):
    if i > j:
        i, j = j, i
    return id[i][j]

# 頂点番号のラベリング
V = 0
for i in range(n):
    for j in range(n):
        if i < j:
            id[i][j] += V
            V += 1

# aを、頂点番号に書き換え、試合の依存関係を表す辺を張る(辺の向きは逆にする)
for i in range(n):
    for j in range(n-1):
        a[i][j] = toID(i, a[i][j])
    for j in range(n-2):
        to[a[i][j+1]].append(a[i][j])

# dfsする
visited = [False for _ in range(MAXV)]
calculated = [False for _ in range(MAXV)] # loop 検出用
dp = [0 for _ in range(MAXV)] # max length of path from v
def dfs(v):
    if visited[v]:
        if not calculated[v]:
            return -1
        return dp[v]
    visited[v] = True
    dp[v] = 1
    for u in to[v]:
        res = dfs(u)
        if res == -1:
            return -1
        dp[v] = max(dp[v], res+1)
    calculated[v] = True
    return dp[v]

ans = 0
ok = True
for i in range(V):
    res = dfs(i)
    if res == -1:
        ok = False
        break
    ans = max(ans, res)
if ok:
    print(ans)
else:
    print(-1)
### BUGGY CODE ###

import sys
from operator import itemgetter
inputs = sys.stdin.readline
N, Q= map(int,inputs().split())
def main():
	E = [None]*2*N
	for n in range(N):
		a,b,c = map(int,inputs().split())
		E[2*n] = (a - c, 1, c)
		E[2*n + 1] = (b - c, -1, c)
	E.sort(key=itemgetter(0))
	tuple(tuple(E))
	mini = 1000000001
	kouho = {1000000001}
	my_add = kouho.add
	my_discard = kouho.discard
	q = 0
	d = int(inputs())
	flag = False
	cont = False
	for e in E:
		while(e[0] > d):
			if cont == True:
				if mini < 1000000001:
					print(mini)
				else:
					print(-1)
			else:
				mini = min(kouho)
				if mini < 1000000001:
					print(mini)
				else:
					print(-1)
			cont = True
			if q < Q-1:
				q = q + 1
				d = int(inputs())
			else:
				flag = True
				q = q + 1
				break
		if flag == True:
			break
		if e[1] == 1:
			my_add(e[2])
			if mini > e[2]:
				mini = e[2]
		elif e[1] == -1:
			my_discard(e[2])
			cont = False
	for t in [None]*(Q-q):
		print(-1)
		
def sub():
	V = [list(map(int,inputs().split())) for p in [0]*N]
	M = [int(inputs()) for p in [0]*Q]
	V.sort(key = lambda x:(x[2],x[0],x[1]))
	for v in V:
		v[0] -= v[2]
		v[1] -= v[2] + 1
	for m in M:
		for n in range(N):
			if V[n][0] <=m and m <= V[n][1]:
				print(V[n][2])
				break
		else:
			print(-1)


if N > 10000*Q:
	sub()
else:
	main()

### FIXED CODE ###

import sys
from operator import itemgetter
def main():
	inputs = sys.stdin.readline
	N, Q= map(int,inputs().split())
	E = [None]*2*N
	for n in range(N):
		a,b,c = map(int,inputs().split())
		E[2*n] = (a - c, 1, c)
		E[2*n + 1] = (b - c, -1, c)
	E.sort(key=itemgetter(0))
	tuple(tuple(E))
	mini = 1000000001
	kouho = {1000000001}
	my_add = kouho.add
	my_discard = kouho.discard
	q = 0
	d = int(inputs())
	flag = False
	cont = False
	for e in E:
		while e[0] > d:
			if cont == True:
				print(mini-(mini//1000000001)*1000000002)
			else:
				mini = min(kouho)
				print(mini-(mini//1000000001)*1000000002)
			cont = True
			q = q + 1
			if q > Q-1:
				flag = True
				break
			d = int(inputs())
		if flag == True:
			break
		if e[1] == 1:
			my_add(e[2])
			if mini > e[2]:
				mini = e[2]
		elif e[1] == -1:
			my_discard(e[2])
			if mini == e[2]:
				cont = False
	for t in [None]*(Q-q):
		print(-1)
main()
### BUGGY CODE ###

# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math



def gcd_ab(a,b):
  while a != b:
    a,b = sorted([a,b])
    if a == 0:
      return b
    b = b-a
  return a


if __name__ == "__main__": 
  N = int(input())
  An = list(map(int, sys.stdin.readline().rstrip().split()))
  cuml = An.copy()
  cumr = An.copy()

  for i in range(1, N):
    cuml[i] = gcd_ab(cuml[i-1], An[i])
    cumr[N-i-1] = gcd_ab(cumr[N-i], An[N-i-1])

  cuml = [0] + cuml + [0]
  cumr = [0] + cumr + [0]

  ans = 0
  for i in range(1,N+1):
    ans = max(ans, gcd_ab(cuml[i-1], cumr[i+1]))
  print(ans)

### FIXED CODE ###

# /usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math


def gcd_ab(a,b):
  a,b = sorted([a,b])
  if a == 0:
    return b
  return gcd_ab(b%a, a)

if __name__ == "__main__": 
  N = int(input())
  An = list(map(int, sys.stdin.readline().rstrip().split()))
  cum = [[0,0] for i in range(N+2)]

  for i in range(N):
    cum[i+1][0] = gcd_ab(cum[i][0], An[i])
    cum[N-i][1] = gcd_ab(cum[N-i+1][1], An[N-i-1])

  ans = [0 for i in range(N)]
  for i in range(1,N+1):
    ans[i-1] = gcd_ab(cum[i-1][0], cum[i+1][1])
  print(max(ans))
### BUGGY CODE ###

n = int(input())
t_all, a_all = 0, 0
for i in range(n):
    t, a = map(int, input().split())
    if i == 0:
        t_all += t
        a_all += a
    else:
        diff1, diff2 = 0, 0
        diff1 = t_all // t if t_all % t == 0 else t_all // t + 1
        diff2 = a_all // a if a_all % a == 0 else a_all // a + 1
        max_diff = max(diff1, diff2)
        for x in range(1, max_diff+1):
            if t * x >= t_all and a * x >= a_all:
                t_all = t * x
                a_all = a * x
                break
print(t_all + a_all)
        


### FIXED CODE ###

n = int(input())
t_all, a_all = 0, 0
for i in range(n):
    t, a = map(int, input().split())
    if i == 0:
        t_all = t
        a_all = a
    else:
        if t >= t_all and a >= a_all:
            t_all, a_all = t, a
        else:
            diff1, diff2 = 0, 0
            diff1 = t_all // t if t_all % t == 0 else t_all // t + 1
            diff2 = a_all // a if a_all % a == 0 else a_all // a + 1
            max_diff = max(diff1, diff2)
            t_all = t * max_diff
            a_all = a * max_diff
print(t_all + a_all)
### BUGGY CODE ###

from collections import defaultdict,deque
N = int(input())
A = defaultdict(int)
for i in input().split():
    A[int(i)] += 1
D = set()
S = []
for key in A.keys():
    if A[key] >= 2:
        D.add(key)
    S.append(key)
S = sorted(S)
Q = deque(S)
ans = 0
while Q:
    q = Q.popleft()
    if q not in D:
        ans += 1
    R = []
    while Q:
        M = Q.popleft()
        if M%q != 0:
            R.append(M)
    Q = deque(R)
print(ans)

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
max_a = max(a)
cnt_d = [0] * (max_a + 1)
for ai in a:
    for multi in range(ai, max_a + 1, ai):
        cnt_d[multi] += 1
print(sum(cnt_d[ai] == 1 for ai in a))
### BUGGY CODE ###

p=10**9+7

n,m=map(int,input().split())
x=list(map(int,input().split()))
w=[x[i+1]-x[i] for i in range(n-1)]
y=list(map(int,input().split()))
h=[y[k+1]-y[k] for k in range(m-1)]

ans=0

for i in range (n-1):
    for k in range(m-1):
        ans=(ans+w[i]*h[k]*(1+i)*(n-i-1)*(1+k)*(m-k-1))%p

print(ans)

### FIXED CODE ###

p=10**9+7

n,m=map(int,input().split())
x=list(map(int,input().split()))
w=[((x[i+1]-x[i])*(1+i)*(n-i-1))%p for i in range(n-1)]
y=list(map(int,input().split()))
h=[((y[k+1]-y[k])*(1+k)*(m-k-1))%p for k in range(m-1)]

print(((sum(w)%p)*(sum(h)%p)%p))
### BUGGY CODE ###

N,K = map(int, input().split())
answer = list(map(lambda x: (1+x)/2, list(map(int, input().split()))))
total = 0
for i in range(0,N-K+1):
    total = max(total, sum(answer[i:i+K]))
print(total)

### FIXED CODE ###

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

S = [0]*(N+1)
for i in range(N):
  S[i+1] = S[i] + (1+p[i])/2

ans = 0
for i in range(N-K+1):
  diff = S[i+K] - S[i]
  ans = max(ans, diff)
print(ans)
### BUGGY CODE ###

X = 1
N = int(input())
A = list(map(int,input().split()))
for i in A:
  X *= i
if X > 10 ** 18:
  print("-1")
else:
  print(X)


### FIXED CODE ###

def demon():
  N = int(input())
  A = list(map(int,input().split()))
  A.sort()
  if A[0] == 0:
    print(0)
    return

  X = 1
  for i in A:
    X *= i
    if X > 10 ** 18:
      print("-1")
      return

  print(X)

demon()
### BUGGY CODE ###

from operator import mul
from functools import reduce
from collections import Counter
from copy import deepcopy

def main():

    def cmb(n,r):
        r = min(n-r,r)
        if r == 0: return 1
        over = reduce(mul, range(n, n - r, -1))
        under = reduce(mul, range(1,r + 1))
        return over // under

    n = int(input())
    A = [int(x) for x in input().split()]
    a_c= Counter(A)
    values = a_c.values()
    val_cnt = Counter(values)
    cnt = 0
    for a in A:
        a_c_c = deepcopy(a_c)
        val_cnt_c = deepcopy(val_cnt)
        val_cnt_c[a_c_c[a]] -= 1
        val_cnt_c[a_c_c[a]-1] += 1
        cnt = {cmb(k, 2) * v  if k > 1 else 0 for k, v in val_cnt_c.items()}
        print(sum(cnt))
    
if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import Counter
 
def main():
    n = int(input())
    A = [int(x) for x in input().split()]
    a_c = Counter(A)
    res = [int(v*(v-1)/2) for v in a_c.values()]
    cnt = sum(res)
    for a in A:
        ans = (cnt - (a_c[a]-1))
        print(ans)
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

s = input()
q = int(input())
tmp = s
flag = 0
for _ in range(q):
    _s = input()
    t = 0
    f = 0
    c = ""
    if _s == "1":
        flag += 1
    else:
        t, f, c = _s.split(" ")
        if f == "1" and flag % 2 == 0:
            tmp = c + tmp
        elif f == "1" and flag % 2 == 1:
            tmp = tmp + c
        elif f == "2" and flag % 2 == 0:
            tmp = tmp + c
        elif f == "2" and flag % 2 == 1:
            tmp = c + tmp
if flag % 2 == 0:
    print(tmp)
else:
    print(tmp[::-1])
        

### FIXED CODE ###

from collections import deque
s = input()
q = int(input())
tmp = deque()
for i in range(len(s)):
    tmp.append(s[i])
flag = 0
for _ in range(q):
    _s = input()
    if _s == "1":
        flag += 1
    else:
        t, f, c = _s.split(" ")
        r = flag % 2
        if f == "1" and r == 0:
            #tmp = c + tmp
            tmp.appendleft(c)
        elif f == "1" and r == 1:
            #tmp = tmp + c
            tmp.append(c)
        elif f == "2" and r == 0:
            #tmp = tmp + c
            tmp.append(c)
        elif f == "2" and r == 1:
            #tmp = c + tmp
            tmp.appendleft(c)
if flag % 2 == 0:
    for i in range(len(tmp)):
        print(tmp.popleft(), end="")
else:
    for i in range(len(tmp)):
        print(tmp.pop(), end="")
### BUGGY CODE ###

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

ret = 0

for a in range(1, N + 1):
    if 2 * a % K != 0:
        continue

    cnt = 0
    t = 1
    while t * K - a <= N:
        if t * K - a >= 1:
            cnt += 1
        t += 1

    ret += cnt ** 2

print(ret)


### FIXED CODE ###

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

x, y = 0, 0

for i in range(1, N + 1):
    if i % K == 0:
        x += 1
    if K % 2 == 0 and i % K == K // 2:
        y += 1

print(x ** 3 + y ** 3)
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
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 LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	n = II()
	a = LI()
	a = [0]+a
	dp_t = [[-10**9-1 for _ in range(n//2+2)] for _ in range(n+1)]
	dp_f = [[-10**9-1 for _ in range(n//2+2)] for _ in range(n+1)]
	dp_f[0][0]=0
	for i in range(1,n+1):
		dp_f[i][(i-1)//2]=max(dp_f[i-1][(i-1)//2], dp_t[i-1][(i-1)//2])
		dp_t[i][(i-1)//2]=dp_f[i-1][(i-1)//2-1]+a[i]
		dp_f[i][(i-1)//2+1]=max(dp_f[i-1][(i-1)//2+1], dp_t[i-1][(i-1)//2+1])
		dp_t[i][(i-1)//2+1]=dp_f[i-1][(i-1)//2]+a[i]
	print(max(dp_t[n][n//2],dp_f[n][n//2]))
if __name__ == '__main__':
	main()

### FIXED CODE ###

import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
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 LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	n = II()
	a = LI()
	a = [0]+a
	dp_t = defaultdict(lambda: -10**18)
	dp_f =  defaultdict(lambda: -10**18)
	dp_f[(0,0)]=0
	for i in range(1,n+1):
		dp_f[(i,(i-1)//2)]=max(dp_f[(i-1,(i-1)//2)], dp_t[(i-1,(i-1)//2)])
		dp_t[(i,(i-1)//2)]=dp_f[(i-1,(i-1)//2-1)]+a[i]
		dp_f[(i,(i-1)//2+1)]=max(dp_f[(i-1,(i-1)//2+1)], dp_t[(i-1,(i-1)//2+1)])
		dp_t[(i,(i-1)//2+1)]=dp_f[(i-1,(i-1)//2)]+a[i]
	print(max(dp_t[(n,n//2)],dp_f[(n,n//2)]))
if __name__ == '__main__':
	main()
### BUGGY CODE ###

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

ls = sorted(l)

count = 0
for i in range(n):
    for j in range(i+1, n):
        x, y = ls[i], ls[j]
        index = bisect.bisect_left(ls[j+1:], x + y)
        count += index
print(count)

### FIXED CODE ###

import bisect
n = int(input())
l = list(map(int,input().split()))
ls = sorted(l)

count = 0
for i in range(n):
    for j in range(i+1, n):
        index = bisect.bisect_left(ls[j+1:], ls[i] + ls[j])
        count += index
print(count)