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

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

tmp_p = []
for p in P:
    tmp = ((1+p)*p/2)/p
    tmp_p.append(tmp)
ans = 0
for i in range(n-k+1):
    ans = max(ans, sum(tmp_p[i:k+i]))
print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
P = list(map(int,input().split()))
check = [0]*1001
tmp_p = []
for p in P:
    if check[p]!=0:
        tmp_p.append(check[p])
    else:
        tmp = ((1+p)*p/2)/p #期待値の計算
        tmp_p.append(tmp)
ans = sum(tmp_p[0:k])
tmp_ans = ans
for i in range(n-k):
    tmp_ans += (tmp_p[k+i]-tmp_p[i])
    ans = max(ans, tmp_ans)
print(ans)
### BUGGY CODE ###

lis = list(map(int, input().split()))
lis2 = list(map(int, input().split()))
n = lis[0]
k = lis[1]
a = []
b = []
for i in range(n):
    if lis2[i] not in a:
        a.append(lis2[i])
        count = 1
        for j in range(i+1,n):
            if lis2[j] == lis2[i]:
                count += 1
        b.append(count)

if len(b) <= k:
    print(0)
else:
    b.sort()
    b.reverse()
    swap = 0
    for i in range(k,len(b)):
        swap += b[i]
    print(swap)

### FIXED CODE ###

lis = list(map(int, input().split()))
lis2 = input().split()
n = lis[0]
k = lis[1]
d = {}

for i in range(n):
    if lis2[i] not in d.keys():
       d[lis2[i]] = 1
    else:
        d[lis2[i]] += 1 
        
if len(list(d.values())) <= k:
    print(0)
else:
    a = list(d.values())
    a.sort()
    a.reverse()
    swap = 0
    for i in range(k,len(a)):
        swap += a[i]
    print(swap)
### BUGGY CODE ###

N = int(input())
L = list(map(int, input().split()))
L.sort()

ans = 0
ans2 = 0
for k in range(N-2):
  for j in range(k+1, N-1):
    cnt = 0
    for l in range(N-1, j, -1):
      if L[k] + L[j] <= L[l]:
        cnt += 1
        continue
      else:
        ans += N-1-j-cnt
        break
print(ans)

### FIXED CODE ###

# Binary Indexed Tree (Fenwick Tree)
class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0]*(n+1)
        self.el = [0]*(n+1)
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s
    def add(self, i, x):
        # assert i > 0
        self.el[i] += x
        while i <= self.n:
            self.data[i] += x
            i += i & -i
    def get(self, i, j=None):
        if j is None:
            return self.el[i]
        return self.sum(j) - self.sum(i)


N = int(input())
L = list(map(int, input().split()))
L.sort()
bit = BIT(L[-1]*2+1)
bit.add(L[0]+L[1], 1)
total = 1
ans = 0
for k in range(2, N):
  ans += total - bit.sum(L[k])
  for j in range(k):
    bit.add(L[j]+L[k], 1)
    total += 1

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

import sys
N, K = map(int, input().split())
A = list(map(int, input().split()))
c = 0

while(True):
    p = 0
    T = [0]*N
    for i in range(N):
        for j in range(max(i-A[i], 0), min(i+A[i]+1, N)):
            T[j] += 1
    c += 1
    if c == K:
        for i in range(N):
            print(T[i], end=" ")
        sys.exit()
    for i in range(N):
        if T[i] <= N:
            p = 1
            break
    if p == 0:
        for i in range(N):
            print(N, end= " ")
        sys.exit()
    A = T[:]

### FIXED CODE ###

import sys
N, K = map(int, input().split())
A = list(map(int, input().split()))
c = 0

while(True):
    p = 0
    T = [0]*N
    for i in range(N):
        T[max(i-A[i], 0)] += 1
        if i+A[i]+1 > N - 1:
            pass
        else:
            T[i+A[i]+1] -= 1
    for i in range(1,N):
        T[i] += T[i-1]
    c += 1
    if c == K:
        for i in range(N):
            print(T[i], end=" ")
        sys.exit()
    for i in range(N):
        if T[i] < N:
            p = 1
            break
    if p == 0:
        for i in range(N):
            print(N, end= " ")
        sys.exit()
    A = T[:]
### BUGGY CODE ###

def main():
    s = list(input())
    q = int(input())
    S = ''
    for i in range(q):
        li = input().split()
        if li[0] == '1':
            s.reverse()
        else:
            if li[1] == '1':
                s = [li[2]]  + s
            else:
                s = s + [li[2]]
    for i in s:
        S += i
    print(S)

if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import deque

s = input()
q = int(input())
S = deque(s)
head = True

for i in range(q):
    li = input().split()
    if li[0] == '1':
        head = not head
    else:
        if head:
            if li[1] == '1':
                S.appendleft(li.pop())
            else:
                S.append(li.pop())
        else:
            if li[1] == '2':
                S.appendleft(li.pop())
            else:
                S.append(li.pop())
s = ''.join(S)
if not head:
    s = s[::-1]
print(s)
### BUGGY CODE ###

import math
A,B,N= map(int,input().split())

list=[]
for i in range(N+1):
    list.append(math.floor((A*i)/B)-A*(math.floor(i/B)))

print(max(list))


### FIXED CODE ###

import math
A,B,N= map(int,input().split())

if B<=N:
    lista=(math.floor((A*(B-1))/B)-A*(math.floor((B-1)/B)))
    print(lista)
else:
    list=(math.floor((A*N)/B)-A*(math.floor(N/B)))
    print(list)
### BUGGY CODE ###

aa=[]
a=int(input())
for i in range(0,a):
  aa.append(input().split(" "))

bb=[]
for j in range(0,a):
  bb.append(input().split(" "))

#print(aa)
#print(bb)
  
pattern=[]
zentai=[]
chouhuku=0

for m in range(0,a**a):
  for n in range(0,a):
    pattern.append(m//(a**n)%a)
    
  #print(pattern)
  
  for w in range(0,a):
    if pattern.count(pattern[w])>=2:
      chouhuku=1
  
  if chouhuku==0:
    zentai.append(pattern)
  pattern=[]
  chouhuku=0
  
#print(zentai)

score=0
max=0

for ww in zentai:
  for z in range(0,a):
    if aa[z][0]<bb[int(ww[z])][0] and aa[z][1]<bb[int(ww[z])][1]:
      score=score+1
  #print(ww)
  #print ("score="+str(score))
  if max<=score:
    max=score
  score=0

print(max)


### FIXED CODE ###

#解答確認後
n=int(input())
aa=[[int(i) for i in input().split()] for i in range(n)]
bb=[[int(i) for i in input().split()] for i in range(n)]

#print(aa)
#print(bb)

import operator
aa.sort(key=operator.itemgetter(1),reverse=True)
bb.sort()
  
#print(aa)
#print(bb)

answer=0
for b in bb:
  xb,yb=b
  for a in aa:
    xa,ya=a
    if xa<xb and ya<yb:
      answer=answer+1
      aa. remove (a)
      #print(aa)
      #print(bb)
      #print(answer)
      break
      
print(answer)
### BUGGY CODE ###

n, s = map(int, input().split())
a = list(map(int, input().split()))
mod = 998244353
ans = 0

dp = [[{} for _ in range(s+1)] for _ in range(n+1)]
dp[0][0] = {0: 1}

for i in range(n):
    for j in range(s+1):
        for k in dp[i][j].keys():
            if k in dp[i+1][j]:
                dp[i+1][j][k] += dp[i][j][k]
            else:
                dp[i+1][j][k] = dp[i][j][k]

            if j + a[i] <= s:
                if k+1 in dp[i+1][j+a[i]]:
                    dp[i+1][j+a[i]][k+1] += dp[i][j][k]
                else:
                    dp[i+1][j+a[i]][k+1] = dp[i][j][k]


for k in dp[n][s].keys():
    ans = (ans + dp[n][s][k] * pow(2, n-k, mod) % mod) % mod

print(ans)

### FIXED CODE ###

n, s = map(int, input().split())
a = list(map(int, input().split()))
mod = 998244353
ans = 0

inv_2 = pow(2, mod-2, mod)
dp = [[0 for _ in range(s+1)] for _ in range(n+1)]
dp[0][0] = pow(2, n, mod)

for i in range(n):
    for j in range(s+1):
        dp[i+1][j] += dp[i][j]
        dp[i+1][j] %= mod

        if j + a[i] <= s:
            dp[i+1][j+a[i]] += dp[i][j] * inv_2
            dp[i+1][j+a[i]] %= mod

#print(dp)
print(dp[n][s])
### BUGGY CODE ###

n, p = [int(i) for i in input().split()]
s = input()

cnt = 0
for i in range(n):
    for k in range(i+1, n+1):
        if int(s[i:k]) % p == 0:
            cnt += 1

print(cnt)


### FIXED CODE ###

n, p = map(int, input().split())
s = input()

res = 0
if p == 2 or p == 5:
    for i in range(n):
        if int(s[i]) % p == 0:
            res += i + 1
else:
    s = s[::-1]
    cnt = {0: 1}
    now = 0
    d = 1
    for i in range(n):
        now = (now + int(s[i]) * d) % p
        res += cnt.get(now, 0)
        d = (d * 10) % p
        cnt[now] = cnt.get(now, 0) + 1

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

N = int(input())

A = input().split()  

answer = 1

for i in range(N) :
    answer = answer * int(A[i])


if answer > 1000000000000000000 : 
    print('-1')
    quit()


print(answer)     

### FIXED CODE ###

N = int(input())

A = input().split()  

answer = 1

sort = sorted(A)

for i in range(N) :
    answer = answer * int(sort[i])
    if answer == 0:
        print('0')
        quit()
    if answer > 1000000000000000000 : 
        print('-1')
        quit()


print(answer)
### BUGGY CODE ###

# 初期入力
N = int(input())
#A = list(map(int, input().split()))
A = list(map(int, input().split()))

#　1の左側は砕く、以降数字が大きくなるほど右側にあればいいが、順番が違うと砕く必要あり。
from copy import deepcopy
#B =deepcopy(A)
#B = "".join(A)
x = 0
y =0
z = []
for i in range(1,N+1):
    if i in A:
        y = A.index(i ) 
        z.append(y)
        x = y
        del A[:x] 
    else:
        y = -1
        break
#
renga_kudaku = 0
if len(z) ==0 and y==-1:
    renga_kudaku = -1
elif len(z) ==0:
    renga_kudaku = 0
else:
    renga_kudaku=sum(z)-len(z) +1 +(len(A)-1) # 1の左側はリストの「０」あるので＋１、len(B)-1=最後の「B]の右側の文字数
print(renga_kudaku)

### FIXED CODE ###

#初期入力
import sys
N = int(input())
A=[int(i) for i in input().split()]
#


if 1 not in A:
    print(-1)
    exit
else:
    i=1 #探す数字
    brick_remain =set() #「1」は入っていること上記で確かめた
    for a in A:
        if a ==i:
            brick_remain.add(a)
            i +=1
    brick_destroy = N - len(brick_remain)       
    print(brick_destroy)
### BUGGY CODE ###

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


ans = 1
tmp = P
start = P // (2**N) + 1
for i in range(start, 1, -1):
    newtmp, rest = divmod(tmp, (i**N))
    if rest == 0:
        ans = ans * i
        tmp = newtmp

print(ans)


### FIXED CODE ###

N, P = list(map(int, input().split()))
if N == 1:
    print(P)
    exit()
elif P == 1:
    print("1")
    exit()

ans = 1
tmp = P

for i in range(2, int(pow(P, 1 / N)) + 1):
    po = pow(i, N)
    while tmp % po == 0:
        tmp = tmp // po
        ans = ans * i
        # print(i, tmp, ans)

    if tmp < po:
        break

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

A, B = map(int, input().split())
while True:
  B += 1
print(B)

### FIXED CODE ###

A, B = map(int, input().split())
print(max(A*2-1,A+B,B*2-1))
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N,K = map(int,S().split())
A = LI()

from itertools import accumulate

ANS = A+[0]

for i in range(K):
    B = [0]*(N+1)
    for j in range(N):
        B[max(0,j-ANS[j])] += 1
        B[min(N,j+ANS[j]+1)] -= 1
    ANS = list(accumulate(B))

del ANS[N]
print(*ANS)

### FIXED CODE ###

import sys

def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def S(): return sys.stdin.readline().rstrip()

N,K = map(int,S().split())
A = LI()

from itertools import accumulate

ANS = A+[0]

for i in range(K):
    B = [0]*(N+1)
    for j in range(N):
        B[max(0,j-ANS[j])] += 1
        B[min(N,j+ANS[j]+1)] -= 1
    ANS = list(accumulate(B))
    for i in range(N):
        if ANS[i] != N:
            break
    else:
        break

del ANS[N]
print(*ANS)
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = readline().rstrip().decode()
t = readline().rstrip().decode()
s_size = len(s)
t_size = len(t)
dp = [[0] * (t_size + 1) for _ in range(s_size + 1)]
ans = ''
for i in range(s_size):
    for j in range(t_size):
        if s[i] == t[j]:
            if dp[i + 1][j + 1] < dp[i][j] + 1:
                dp[i + 1][j + 1] = dp[i][j] + 1
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j], dp[i][j + 1])
while s_size > 0 and t_size > 0:
    if dp[s_size][t_size] == dp[s_size - 1][t_size]:
        s_size -= 1
    elif dp[s_size][t_size] == dp[s_size][t_size - 1]:
        t_size -= 1
    else:
        ans = s[s_size - 1] + ans
        s_size -= 1
        t_size -= 1
print(ans)


### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = readline().rstrip().decode()
t = readline().rstrip().decode()
s_size = len(s)
t_size = len(t)
dp = [[0] * (t_size + 1) for _ in range(s_size + 1)]
ans = ''
for i in range(s_size):
    for j in range(t_size):
        if s[i] == t[j]:
            if dp[i + 1][j + 1] < dp[i][j] + 1:
                dp[i + 1][j + 1] = dp[i][j] + 1
        dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i + 1][j], dp[i][j + 1])
while s_size > 0 and t_size > 0:
    if dp[s_size][t_size] == dp[s_size - 1][t_size]:
        s_size -= 1
    elif dp[s_size][t_size] == dp[s_size][t_size - 1]:
        t_size -= 1
    else:
        ans = s[s_size - 1] + ans
        s_size -= 1
        t_size -= 1
print(ans)
### BUGGY CODE ###

K = int(input())

cnt=1
Num=7
while True:
  if K%2==0:
    print('-1')
    break
  if Num%K==0:
    print(cnt)
    break
  else:
    Num+=7*10**cnt
    cnt+=1
    



### FIXED CODE ###

K = int(input())

cnt=1
Num=7%K
while cnt<=K:
  if K%2==0:
    print('-1')
    break
  if Num%K==0:
    print(cnt)
    break
  else:
    Num = (10*Num + 7)%K
    cnt+=1
else:
  print('-1')
### BUGGY CODE ###

def main():
    # n = int(input())
    n, q = map(int, input().split())
    # a = list(map(int, input().split()))
    s = input()
    # h = [int(input()) for _ in rane(n)]
    lr = []
    for i in range(q):
        l, r = list(map(int, input().split()))
        lr.append([l-1, r-1])

    count = [0] * (10 ** 6)
    for i in range(1, n):
        if s[i-1] == "A" and s[i] == "C":
            count[i] = 1

    for i in range(q):
        print(sum(count[lr[i][0]+1:lr[i][1]+1]))


if __name__ == '__main__':
    main()


### FIXED CODE ###

import itertools
import math

n, q = map(int, input().split())
s = input()
lr = []
for i in range(q):
    li , ri = list(map(int, input().split()))
    lr.append([li-1,ri-1])

his = [0]*n
count = 0
for i in range(1,n):
    if s[i-1] == 'A' and s[i] == 'C':
        count += 1
        his[i] = count
    else:
        his[i] = his[i-1]

for i in range(q):
    print(his[lr[i][1]] - his[lr[i][0]])
### BUGGY CODE ###

a, b, x = map(int, input().split())
cnt = 0
for i in range(a, b+1):
    if i%x == 0:
        cnt += 1

print(cnt)

### FIXED CODE ###

a, b, x = map(int, input().split())
print(round(b // x) - round((a - 1) // x))
### BUGGY CODE ###

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

cost = [[float("inf") for i in range(n)] for i in range(n)] 
to=[[] for i in range(n)]
for i in range(m):
    x,y = map(int,input().split())
    to[x-1].append(y-1)
    to[y-1].append(x-1)
dist=[0]*n    
flag=[False]*n
flag[0]=True
que=[]
que.append(0)
while(False in flag):
    v=que.pop(0)
    for i in to[v]:
        if(flag[i]==False):
            dist[i]=v+1
            flag[i]=True
            que.append(i)
        


print("Yes")
for i in dist[1:]:
    print(i)    


### FIXED CODE ###

from collections import deque
n,m=map(int,input().split())
to=[[] for i in range(n)]
for i in range(m):
    x,y = map(int,input().split())
    to[x-1].append(y-1)
    to[y-1].append(x-1)
dist=[None]*n    

que=deque([0])
while que:
    v=que.pop()
    for i in to[v]:
        if(dist[i] is None):
            dist[i]=v+1
            que.appendleft(i)
        
print("Yes")
for i in dist[1:]:
    print(i)
### BUGGY CODE ###

n = int(input())
s = input()
c = 0
for i in range(n):
	for j in range(i+1, n):
		for k in range(j+1, n):
			if s[i] != s[j] and s[j] != s[k] and s[i] != s[k] and (k-j) != (j-i):
				c += 1
print(c)


### FIXED CODE ###

n = int(input())
s = input()
# B_map = set()
R, G, B = 0, 0, 0
for i in range(n):
	if s[i] == 'R':
		R += 1
	elif s[i] == 'G':
		G += 1
	else:
		B += 1

res = R * G * B

for i in range(n):
	for j in range(i+1, n):
		temp = 2*j - i
		if temp < n and s[i] != s[j] and s[j] != s[temp] and s[temp] != s[i]:
			res -= 1
print(res)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def main():
    n,s = map(int,input().split())
    a = list(map(int,input().split()))

    mod = 998244353

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

    for i in range(n):
        if a[i]-1 < s:
            dp[i][a[i]-1] += 2**i
            dp[i][a[i]-1] %= mod

    for i in range(n):
        for j in range(s):
            if i != n-1:
                dp[i+1][j] += dp[i][j] * 2
                dp[i+1][j] %= mod
            if i != n-1 and j + a[i+1] < s:
                dp[i+1][j+a[i+1]] += dp[i][j]
                dp[i+1][j+a[i+1]] %= mod

    print(dp[-1][-1]%mod)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    n,s = map(int,input().split())
    a = list(map(int,input().split()))

    mod = 998244353

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

    for i in range(n):
        if a[i]-1 < s:
            dp[i][a[i]-1] += pow(2,i,mod)
            dp[i][a[i]-1] %= mod

    for i in range(n):
        for j in range(s):
            if i != n-1:
                dp[i+1][j] += dp[i][j] * 2
                dp[i+1][j] %= mod
            if i != n-1 and j + a[i+1] < s:
                dp[i+1][j+a[i+1]] += dp[i][j]
                dp[i+1][j+a[i+1]] %= mod

    print(dp[-1][-1]%mod)

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


s = input()
t = input()
ls, lt = len(s), len(t)

dp_list = [ [ ("",0) for i in range(ls+1) ] for j in range(lt+1) ]

for i in range(lt):
    for j in range(ls):
        if t[i] == s[j]:
            a = dp_list[i][j][1] + 1 
            b = dp_list[i+1][j][1]
            c = dp_list[i][j+1][1]
            p = [a,b,c].index(max(a,b,c))
            if p == 0:
                dp_list[i+1][j+1] = ( dp_list[i][j][0] + s[j] , a) 
            elif p == 1:
                dp_list[i+1][j+1] = dp_list[i+1][j]
            elif p == 2:
                dp_list[i+1][j+1] = dp_list[i][j+1]
        else:
            a = dp_list[i][j][1] 
            b = dp_list[i+1][j][1]
            c = dp_list[i][j+1][1]
            p = [a,b,c].index(max(a,b,c))
            if p == 0:
                dp_list[i+1][j+1] = dp_list[i][j]
            elif p == 1:
                dp_list[i+1][j+1] = dp_list[i+1][j]
            elif p == 2:
                dp_list[i+1][j+1] = dp_list[i][j+1]            
print(dp_list[-1][-1][0])


### FIXED CODE ###

s = input()
t = input()
ls, lt = len(s), len(t)

dp_list = [ [ 0 for i in range(ls+1) ] for j in range(lt+1) ]
index_list = [ [ None for i in range(ls) ] for j in range(lt) ]

for i in range(lt):
    for j in range(ls):
        if t[i] == s[j]:
            a = dp_list[i+1][j]
            b = dp_list[i][j+1]
            c = dp_list[i][j] + 1 
            p = [a,b,c].index(max(a,b,c))
            dp_list[i+1][j+1] = [a,b,c][p]
            index_list[i][j] = (1,p)

        else:
            a = dp_list[i+1][j]
            b = dp_list[i][j+1]
            p = [a,b].index(max(a,b))
            dp_list[i+1][j+1] = [a,b][p]
            index_list[i][j] = (0,p)

q = dp_list[-1][-1]
r = t   

a = 10**5

ans = ""
y, x = lt-1, ls-1
while y != -1 and x != -1:
    if index_list[y][x][1] == 2:
        x -= 1
        y -= 1
        ans += s[x+1]
    elif index_list[y][x][1] == 1:
        y -= 1
    elif index_list[y][x][1] == 0:
        x -= 1

print(ans[::-1])
### BUGGY CODE ###

n = int(input())
ans = 1;
s = input().split()
for i in s:
   ans *= int(i) 
if(ans > 10**18):
    print("-1")
else:
    print(ans)


### FIXED CODE ###

n = int(input())
ans = 1;
tem = 0
ok = 1
s = input().split()
for i in s:
    if(int(i) == 0):
        tem = 1
        break
    if(ok == 1):
        ans *= int(i) 
        if(ans > 10**18):
            ok = 0
if(tem):
    print(0)
elif(ok):
    print(ans)
else:
    print("-1")
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
bf,bs = 0,0
fir = []
sec = []
fi1 = 1
se1 = 1
ans = n
ansf = n
for i in range(3):
  if a[i]>b[i]:
    if b[i] == 1:
      bs = 1
      if se1 < a[i]:
        se1 = a[i]
    else:     
      sec.append((a[i],b[i]))
  else:
    if a[i] == 1:
      bf = 1
      if fi1 < b[i]:
        fi1 = b[i]
    else:
      fir.append((b[i],a[i]))
sec += [(n,n),(n,n),(n,n)]
fir += [(n,n),(n,n),(n,n)]
for p in range(n//fir[0][1]+1):
  for q in range((n-p*fir[0][1])//fir[1][1]+1):
    rg = n - p*fir[0][1] - q*fir[1][1]
    if rg < 0:
      continue
    if bf:
      res = rg
      r = 0
    else:
      res = rg%fir[2][1]
      r = rg//fir[2][1]
    en = p*fir[0][0] + q*fir[1][0] + r*fir[2][0] + res*fi1
    if ansf < en:
      ansf = en
for p in range(ansf//sec[0][1]+1):
  for q in range((ansf-p*sec[0][1])//sec[1][1]+1):
    rg = ansf - p*sec[0][1] - q*sec[1][1]
    if rg < 0:
      continue
    if bs:
      res =  rg
      r = 0
    else:
      res = rg%sec[2][1]
      r = rg//sec[2][1]
    en = p*sec[0][0] + q*sec[1][0] + r*sec[2][0] + res*se1
    if ans < en:
      ans = en
print(ans)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
dp = [0]*(n+1)
fir = []
sec = []
for i in range(3):
  if a[i]>b[i]:
    sec.append((b[i],a[i]))
  else:
    fir.append((a[i],b[i]))
for i in range(1,n+1):
  dp[i] = i
  for x,y in fir:
    if i-x >= 0:
      dp[i] = max(dp[i],dp[i-x]+y)
n = dp[n]
dp = [0]*(n+1)
for i in range(1,n+1):
  dp[i] = i
  for x,y in sec:
    if i-x >= 0:
      dp[i] = max(dp[i],dp[i-x]+y)
print(dp[n])
### BUGGY CODE ###

N = int(input())
S = input()

ans = 0

index_r = [i for i, x in enumerate(S) if x =='R']
index_g = [i for i, x in enumerate(S) if x =='G']
index_b = [i for i, x in enumerate(S) if x =='B']

for r in index_r:
    for g in index_g:
        for b in index_b:
            idxs = sorted([r,g,b])
            if 2*idxs[1] != idxs[0]+idxs[2]:
                ans +=1

print(ans)


### FIXED CODE ###

N = int(input())
S = input()

ans = S.count('R')*S.count('G')*S.count('B')

for i in range(N):
    for j in range(N):
        if i+2*j < N:
            if len(set([S[i],S[i+j],S[i+2*j]]))==3:
                ans -=1
print(ans)
### BUGGY CODE ###

import sys
from collections import Counter
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))

n = INT()
a = LIST()
c = list(set(a))
b = [0 for _ in range(n + 1)]
for i in range(n):
    b[a[i]] += 1
for k in range(n):
    ans = 0
    for i in c:
        tmp = b[i]
        if i == a[k]:
            tmp -= 1
        if tmp >= 2:
            ans += tmp * (tmp - 1) // 2
    print(ans)


### FIXED CODE ###

import sys
from collections import Counter
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def LIST(): return list(map(int, input().split()))

n = INT()
a = LIST()
c = list(set(a))
b = [0 for _ in range(n + 1)]
for i in range(n):
    b[a[i]] += 1
d = [0 for _ in range(n + 1)]
e = [0 for _ in range(n + 1)]
for i in range(n + 1):
    if b[i] >= 2:
        d[i] = b[i] * (b[i] - 1) // 2
    if b[i] >= 3:
        e[i] = (b[i] - 1) * (b[i] - 2) // 2
sd = sum(d)
se = sum(e)
for k in range(n):
    ans = sd - d[a[k]] + e[a[k]]
    print(ans)
### BUGGY CODE ###

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

count = 0
for i in range(N):
    for j in range(N):
        if i != j:
            if a[i] % a[j] == 0:
                break
        if j == N-1:
            count += 1
print(count)


### FIXED CODE ###

N = int(input())
A = sorted(list(map(int, input().split())))
M = A[-1]
b = [True]*(M + 1)

count = 0
for i, a in enumerate(A):
    if not b[a]:
        continue
    for j in range(a, M+1, a):
        b[j] = False
    if i < N-1 and A[i+1] == a:
        continue
    count += 1

print(count)