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

dog_ape = list(map(int,input().split(" ")))
dog_ape.sort()
cut     = (10**9)+7

def kai(n):
    ans = 1
    r   = 0
    for i in range(n):
        ans *= (i+1)**2
    return ans

if dog_ape[0] == dog_ape[1]:
    ans = ( kai(dog_ape[0]) )*2
    ans %= cut
    print(ans)

elif dog_ape[1] - dog_ape[0] == 1:
    ans = kai(dog_ape[0])*(dog_ape[1])
    ans %= cut
    print(ans)

else:
    print(0)  


### FIXED CODE ###

dog_ape = list(map(int,input().split(" ")))
dog_ape.sort()
cut     = (10**9)+7

def kai(n):
    ans = 1
    r   = 0
    for i in range(n):
        ans *= (i+1)**2
        if ans > cut:
            ans %= cut
    return ans

if dog_ape[0] == dog_ape[1]:
    ans = ( kai(dog_ape[0]) )*2
    ans %= cut
    print(ans)

elif dog_ape[1] - dog_ape[0] == 1:
    ans = kai(dog_ape[0])*(dog_ape[1])
    ans %= cut
    print(ans)

else:
    print(0)
### BUGGY CODE ###

def get_input():
    N = int(input())
    numbers = [int(i) for i in input().split()]
    return N, numbers


def DPsolve(N, numbers):
    count = 0
    dp = [[1 for i in range(len(numbers))] for j in range(len(numbers))]
    for i in range(N):
        for j in range(N-i):
            if j == 0:
                dp[i][j] = numbers[i]
            else:
                dp[i][j] = dp[i][j-1] + numbers[i+j]
            if dp[i][j] == 0:
                count += 1
    return dp, count

if __name__ == '__main__':
    N, numbers = get_input()
    dp, count = DPsolve(N, numbers)
    print(count)

### FIXED CODE ###

def get_input():
    N = int(input())
    numbers = [int(i) for i in input().split()]
    return N, numbers

def DPsolve(N, numbers):
    count = 0
    dp = [[1 for i in range(len(numbers))] for j in range(len(numbers))]
    for i in range(N):
        for j in range(N-i):
            if j == 0:
                dp[i][j] = numbers[i]
            else:
                dp[i][j] = dp[i][j-1] + numbers[i+j]
            if dp[i][j] == 0:
                count += 1
    return dp, count

if __name__ == '__main__':
    N, numbers = get_input()
    s = [0]
    for i in range(N):
        s.append(s[-1] + numbers[i])
    s.sort()
    count = 1
    result = 0
    for i in range(N):
        if(s[i] == s[i+1]):
            count += 1
        else:
            result += count * (count -1 ) // 2
            count = 1
    result += count * (count -1 ) // 2
    print(result)
### BUGGY CODE ###

from heapq import heappop, heappush 
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()

    
    def dijkstra():
        def toId(x, y, v): return (x*w+y)*4 + v

        def modCeil(x): return x + (-x)%k

        def push(x, y, v, cost):
            nId = toId(x, y, v)
            if dp[nId] > cost:
                dp[nId] = cost
                heappush(que, (cost, nId))

        inf = 1e18

        dp = [inf]*(h*w*4)
        dp[toId(xs, ys, 0)] = 0

        que = [(0, toId(xs, ys, 0))]
        dx = [-1, 0, 1, 0]
        dy = [0, 1, 0, -1]
        while que:
            cost, Id = heappop(que)
            x = Id//4//w
            y = Id//4%w
            v = Id%4

            if cost > dp[Id]:
                continue
            
            for nv in range(4):
                push(x, y, nv, modCeil(cost))
            
            nx, ny = x+dx[v], y+dy[v]
            if 0 <= nx < h and 0 <= ny < w:
                if field[nx][ny] == '.':
                    push(nx, ny, v, cost+1)

        ans = inf
        for v in range(4):
            ans = min(ans, dp[toId(xg, yg, v)])
        if ans == inf:     
            return -1
        return modCeil(ans)//k

    h, w, k = map(int, input().split())
    xs, ys, xg, yg = map(lambda x: int(x)-1, input().split())
    field = []
    for _ in range(h):
        field.append(input())
    
    ans = dijkstra()
    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from collections import deque
def input(): return sys.stdin.readline().rstrip()

def main():
    
    h, w, k = map(int, input().split())
    xs, ys, xg, yg = map(lambda x: int(x)-1, input().split())
    field = [input() for _ in range(h)]

    inf = 1e7

    dist = [[inf]*w for _ in range(h)]
    dist[xs][ys] = 0
    que = deque([(xs, ys)])
    dx = [-1, 0, 1, 0]
    dy = [0, 1, 0, -1]
    while que:
        x, y = que.popleft()
        for i in range(4):
            nx, ny = x, y
            for _ in range(k):
                nx += dx[i]
                ny += dy[i]
                if nx < 0 or nx >= h or ny < 0 or ny >= w: break
                if field[nx][ny] == '@' or dist[nx][ny] <= dist[x][y]: break
                if dist[nx][ny] > dist[x][y] + 1:
                    dist[nx][ny] = dist[x][y] + 1
                    que.append((nx, ny))
        
    if dist[xg][yg] == inf:
        print(-1)
    else:
        print(dist[xg][yg])
    
if __name__ == '__main__':
    main()
### BUGGY CODE ###

P = 10**9+7
N, K = map(int, input().split())
S = list(map(int, input().split()))
S.sort()
ans = 0
c = 1
for i in range(N-K+1):
    ans += (S[K-1+i]*c)%P
    ans -= (S[N-K-i]*c)%P
    ans %= P
    c = c*(K+i)//(i+1)
print(ans)

### FIXED CODE ###

P = 10**9+7
N, K = map(int, input().split())
S = list(map(int, input().split()))
S.sort()
ans = 0
c = 1
for i in range(N-K+1):
    ans += (S[K-1+i]*c)%P
    ans -= (S[N-K-i]*c)%P
    ans %= P
    c = c*(K+i)*pow(i+1, P-2, P)%P
print(ans)
### BUGGY CODE ###

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

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    

dots = XY[:]

import sys
INT_MAX = sys.maxsize

ans = INT_MAX

import itertools
for left_d, right_d in itertools.permutations(dots, 2):
    if left_d[0] < right_d[0]:
        left_x = left_d[0]
        right_x = right_d[0]
    else:
        left_x = right_d[0]
        right_x =  left_d[0]
    
    for under_d, top_d in itertools.permutations(dots, 2):
        if under_d[1] < top_d[1]:
            under_y = under_d[1]
            top_y = top_d[1]
        else:
            under_y = top_d[1]
            top_y = under_d[1]
            
        counter = 0
        for d in dots:
            if  (left_x <= d[0]) and (d[0] <= right_x) and (under_y <= d[1]) and (d[1] <= top_y):
                counter += 1
                
        if counter >= K:
            area = (top_y-under_y) * (right_x-left_x)
            ans = min(ans, area)
            
print(ans)

### FIXED CODE ###

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

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    
dots = XY[:]

import sys
INT_MAX = sys.maxsize

ans = INT_MAX

import itertools
for ((left_x, _), (right_x, _)) in itertools.combinations(dots, 2):
    if left_x > right_x:
        left_x, right_x = right_x, left_x
    for ((_, under_y), (_, top_y)) in itertools.combinations(dots, 2):
        if under_y > top_y:
            under_y, top_y = top_y, under_y
        counter = 0
        for d_x, d_y in dots:
            if  (left_x <= d_x) and (d_x <= right_x) and (under_y <= d_y) and (d_y <= top_y):
                counter += 1
                
        if counter >= K:
            area = (top_y-under_y) * (right_x-left_x)
            if ans > area:
                ans = area
            
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
D - Knapsack 1
https://atcoder.jp/contests/dp/tasks/dp_d

"""
import sys


def solve(N, W, items):
    dp = [0-1] * (W+1)
    dp[0] = 0
    for w, v in items:
        for i in range(W, w-1, -1):
            if dp[i-w] != -1:
                dp[i] = max(dp[i], dp[i-w]+v)
    return max(dp)



def main(args):
    N, W = map(int, input().split())
    items = [[int(i) for i in input().split()] for _ in range(N)]
    ans = solve(N, W, items)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
D - Knapsack 1
https://atcoder.jp/contests/dp/tasks/dp_d

"""
import sys


def solve(N, W, items):
    ans = {0: 0}
    for w, v in items:
        u = dict()
        for x, y in ans.items():
            if x+w <= W and ans.get(x+w, 0) < y+v:
                u[x+w] = y+v
        ans.update(u)
    return max([v for v in ans.values()])


def main(args):
    N, W = map(int, input().split())
    items = [[int(i) for i in input().split()] for _ in range(N)]
    ans = solve(N, W, items)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])
### BUGGY CODE ###

n = int(input())
items = [tuple(map(int, input().split())) for _ in range(n)]

q = int(input())
v_to_qi = [[] for _ in range(n)]
v_to_l = [[] for _ in range(n)]
flag = [False] * n
for i in range(q):
    v, l = map(int, input().split())
    v -= 1
    v_to_qi[v].append(i)
    v_to_l[v].append(l)
    flag[v] = True
    while v > 0:
        v = (v - 1) // 2
        flag[v] = True

MAX = 10**5
# dp[i+1][j] = (i番目まで見て重さの合計がj以下のの時の価値の最大値)
dp = [[0] * (MAX + 1) for _ in range(20)]
ans = [0] * q


def dfs(v, depth):
    for j in range(MAX + 1):
        if j < items[v][1]:
            dp[depth + 1][j] = dp[depth][j]
        else:
            dp[depth + 1][j] = max(dp[depth][j],
                                   dp[depth][j - items[v][1]] + items[v][0])

    if len(v_to_qi[v]) > 0:
        for i in range(len(v_to_qi[v])):
            ans[v_to_qi[v][i]] = dp[depth + 1][v_to_l[v][i]]

    if v * 2 + 1 < n and flag[v * 2 + 1]:
        dfs(v * 2 + 1, depth + 1)
    if v * 2 + 2 < n and flag[v * 2 + 2]:
        dfs(v * 2 + 2, depth + 1)


dfs(0, 0)
print(*ans, sep='\n')


### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline

    n = int(input())

    L_MAX = 10**5
    D_TH = 10
    V_MAX = (1 << D_TH) - 1
    dp = [[0] * (L_MAX + 1)]
    # items = []
    items_v = []
    items_w = []

    for i in range(n):
        val, w = map(int, input().split())
        if i < V_MAX:
            i1 = i + 1
            i0 = (i + 1) >> 1
            dp_ = dp[i0][:]

            # for j in range(w):
            #     dp[i1][j] = dp[i0][j]
            for j in range(w, L_MAX + 1)[::-1]:
                if dp_[j] < dp_[j - w] + val:
                    dp_[j] = dp_[j - w] + val
            dp.append(dp_)
        else:
            # items.append((val, w))
            items_v.append(val)
            items_w.append(w)

    # items = tuple(items)

    q = int(input())
    for _ in range(q):
        v, l = map(int, input().split())
        v -= 1

        if v < V_MAX:
            ans = dp[v + 1][l]
        else:
            vv = []
            ww = []
            while v >= V_MAX:
                # vv.append(items[v - V_MAX][0])
                # ww.append(items[v - V_MAX][1])
                vv.append(items_v[v - V_MAX])
                ww.append(items_w[v - V_MAX])
                v = (v - 1) >> 1

            ans = dp[v + 1][l]
            # m = len(vv)
            m2 = 1 << len(vv)
            v_sub = [0] * m2
            w_sub = [0] * m2
            for bit in range(1, m2):
                bit_min = bit & (-bit)
                x = bit_min.bit_length() - 1

                s_w = w_sub[bit - bit_min] + ww[x]
                w_sub[bit] = s_w
                if s_w <= l:
                    s_val = v_sub[bit - bit_min] + vv[x]
                    v_sub[bit] = s_val
                    ans = max(ans, dp[v + 1][l - s_w] + s_val)

        print(ans)


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

import numpy as np

N = int(input())

X = np.array(list(map(int,input().split())))

for i in range(N):
    temp = np.r_[X[:i],X[i+1:]]
    print(int(np.median(temp)))

### FIXED CODE ###

N = int(input())

X = list(map(int,input().split()))
sortX = sorted(X)

A = sortX[(N//2)-1]
B = sortX[(N//2)]

for x in X:
    if x<B: print(B)
    else: print(A)
### BUGGY CODE ###

import collections
import math

def combinations_count(n, r): # 組み合わせ nCr
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N = int(input())
a = list(map(int,input().split()))
a_set = collections.Counter(a)
b = list(a_set)
total = 0

for v in b: # 全通り
    if 2 <= a_set[v]:
        total += combinations_count(a_set[v],2)

max_num = max(a_set.values()) # 最大個数
pair_list = [0]*max_num

for n in range(2,max_num+1): # 個数ごとの組み合わせ数を格納
    pair_list[n-1] = combinations_count(n,2)

for v in a:
    if a_set[v] < 2:
        print(total-pair_list[a_set[v]-1])
    else:
        print(total-pair_list[a_set[v]-1]+pair_list[a_set[v]-2])



### FIXED CODE ###

import collections
import math

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

res = 0

for v in a_counter: # 全通り
    res += a_counter[v]*(a_counter[v]-1)//2

for v in a:
    befor = a_counter[v]*(a_counter[v]-1)//2
    after = (a_counter[v]-1)*(a_counter[v]-2)//2
    print(res-befor+after)
### BUGGY CODE ###

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

    x = [[0 for i in range(n)] for j in range(n)]

    for i in range(n - 1):
        for j in range(i + 1, n):
            if i != j and a[i] % a[j] == 0:
                x[i][j] = 1
            if i != j and a[j] % a[i] == 0:
                x[j][i] = 1

    ans = 0
    for i in range(n):
        if sum(x[i]) == 0:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

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

    max_a = max(a) + 1
    dp = [True] * max_a

    for idx in range(len(a)):
        if idx + 1 != len(a) and a[idx] == a[idx + 1]:
            dp[a[idx]] = False
        i = a[idx]
        x = 2
        while i * x < max_a:
            dp[i * x] = False
            x += 1

    ans = 0
    for i in a:
        if dp[i]:
            ans += 1
    print(ans)


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

n=int(input())
import math
from functools import reduce
def gcd_list(*numbers):#引数はリスト
    return reduce(math.gcd, numbers)
ans=n**2
for i in range(2,n+1):
    for j in range(1,n+1):
        for k in range(1,n+1):
            l=[i,j,k]
            ans+=gcd_list(*l)
print(ans)

### FIXED CODE ###

n=int(input())
import math
ans=0
for i in range(1,n+1):
    for j in range(1,n+1):
        ij=math.gcd(i,j)
        if ij==1:
            ans+=n
        else:
            for k in range(1,n+1):
                ans+=math.gcd(ij,k)
print(ans)
### BUGGY CODE ###

n = int(input())
P = list(map(int,input().split()))
ans = 0
for i in range(n):
    if P[i] == min(P[0:i+1]):
        ans += 1
print(ans)

### FIXED CODE ###

n = int(input())
P = list(map(int,input().split()))
ans = 0
mi = P[0]
for i in range(n):
    if P[i] <= mi:
        mi = P[i]
        ans += 1
print(ans)
### BUGGY CODE ###

from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    H, N = map(int, input().split())
    A = [0]*N
    B = [0]*N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    
    dp = [INF] * 10000100
    dp[0] = 0
    for i in range(H):
        if dp[i] == INF:
            continue
        for n in range(N):
            dp[i+A[n]] = min(dp[i+A[n]], dp[i] + B[n])
    
    ans = INF
    for i in range(H, 10000100):
        ans = min(ans, dp[i])
    print(ans)


if __name__ == '__main__':
    main()

### FIXED CODE ###

from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    H, N = map(int, input().split())
    A = [0]*N
    B = [0]*N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    
    dp = [INF] * 10000100
    dp[0] = 0
    for i in range(H):
        if dp[i] == INF:
            continue
        for n in range(N):
            dp[i+A[n]] = min(dp[i+A[n]], dp[i] + B[n])
    
    ans = INF
    for i in range(H, 10000100):
        ans = min(ans, dp[i])
    print(ans)


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

n,w=map(int,input().split())
A=[list(map(int,input().split())) for i in range(n)]

dp=[float("inf")]*(10**5+1)
dp[0]=0
for i in range(n):
  for j in range(10**5,A[i][1]-1,-1):
    dp[j]=min(dp[j],dp[j-A[i][1]]+A[i][0])
ans=0
for v,e in enumerate(dp):
  if e<=w:
    ans=v
print(ans)

### FIXED CODE ###

import sys
input=sys.stdin.readline
n,w=map(int,input().split())
A=[list(map(int,input().split())) for i in range(n)]

dp=[float("inf")]*(10**5+1)
dp[0]=0
for i in range(n):
  for j in range(10**5,A[i][1]-1,-1):
    dp[j]=min(dp[j],dp[j-A[i][1]]+A[i][0])
ans=0
for v,e in enumerate(dp):
  if e<=w:
    ans=v
print(ans)
### BUGGY CODE ###

import copy
S = list(input())
counter = 0
while(True):
    idxs = []
    flag = 0
    
    for i in range(len(S)-1):
        if flag == 1:
            flag = 0
            continue
        if S[i] != S[i+1]:
            idxs.append(i)
            idxs.append(i+1)
            flag = 1
    
    Scopy = []
    for i in range(len(S)):
        if i not in idxs:
            Scopy.append(S[i])
    S = copy.copy(Scopy)
    counter += len(idxs)
    #print(len(idxs))

    if len(idxs) == 0:
        break

print(counter)

### FIXED CODE ###

import copy
S = list(map(int,input()))
cnt0 = 0
cnt1 = 0
for i in range(len(S)):
    if S[i] == 0:
        cnt0 += 1
    else:
        cnt1 += 1

ans = cnt0 + cnt1 - abs(cnt0-cnt1)
print(ans)
### BUGGY CODE ###

N,C = map(int,input().split())
X = [0]*N
V = [0]*N
for i in range(N):
    X[i],V[i] = map(int,input().split())
from numpy import array as arr
X = arr(X)
V = arr(V)
a = []
for i in range(N):
    for j in range(N):
        if i != j:
            k = min(i,j)
            l = max(i,j)
            x = min(2*X[k]+C-X[l],2*(C-X[l])+X[k])
            v = V[:k+1].sum() + V[l:].sum()
            a.append(v-x)
for i in range(N):
    x = X[i]
    v = V[:i+1].sum()
    a.append(max(V[:i+1].sum()-X[i],V[i:].sum()-(C-X[i])))
a.append(0)
a.sort()
print(a[-1])

### FIXED CODE ###

N,C = map(int,input().split())
x1=[]
v1=[]

for i in range(N):
    x,v = map(int,input().split())
    x1.append(x)
    v1.append(v)
x2 = [C-x for x in x1]
v2 = [v for v in v1]
x2.reverse()
v2.reverse()

res1 = 0
res2 = 0
s1 = 0
s2 = 0
r1 = [0]
r2 = [0]
for i in range(N):
    s1 += v1[i]
    s2 += v2[i]
    res1 = max(res1,s1-x1[i])
    res2 = max(res2,s2-x2[i])
    r1.append(res1)
    r2.append(res2)

vl1 = [0]*(N+1)
vl2 = [0]*(N+1)
for i in range(N):
    vl1[i+1] = v2[i]+vl1[i]
    vl2[i+1] = v1[i]+vl2[i]
for i in range(N):
    vl1[i+1] -= 2*x2[i]
    vl2[i+1] -= 2*x1[i]



ans = 0
for i in range(N+1):
    res = vl1[i]+r1[N-i]
    if res > ans:
        ans = res
    res = vl2[i]+r2[N-i]
    if res > ans:
        ans = res

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

import sys

input = sys.stdin.readline

def fact(n):
    fact = [1] * (n + 1)
    for i in range(1, n + 1):
        fact[i] = (fact[i-1] * i) % mod #n!を計算
    return fact[n]

def revfact(n):
    revfact = [1] * (n + 1) #逆元を定義
    revfact[n] = pow(fact(n), mod - 2, mod) #n!のmod-2乗を計算
    for i in reversed(range(1, n)): #N-1から1まで
        revfact[i] = ((i + 1) * revfact[i + 1]) % mod
    return revfact[n]

def comb(n, r):
    return (fact(n) * revfact(n-r) * revfact(r)) % mod

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

ans = 0
for k in range(K + 1):
    ans += (M * pow(M - 1, N - 1 - k, mod) * comb(N - 1, k)) % mod
    ans %= mod
print(ans)

### FIXED CODE ###

import sys

input = sys.stdin.readline

def comb(n, r):
    return (fact[n] * revfact[n-r] * revfact[r]) % mod

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

fact = [1] * (N + 1)
for i in range(1, N + 1):
    fact[i] = (fact[i-1] * i) % mod #n!を計算
# print('fact:{}'.format(fact))
revfact = [1] * (N + 1) #逆元を定義
revfact[N] = pow(fact[N], mod - 2, mod) #n!のmod-2乗を計算
# print('revfact:{}'.format(revfact))
for i in reversed(range(1, N)): #N-1から1まで
    revfact[i] = ((i + 1) * revfact[i + 1]) % mod
# print('revfact:{}'.format(revfact))

ans = 0
for k in range(K + 1):
    ans += (M * pow(M - 1, N - 1 - k, mod) * comb(N - 1, k)) % mod
    ans %= mod
print(ans)
### BUGGY CODE ###

import math

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


for i in range(1, len(a)+1):
    b = a[0:i-1]+a[i:len(a)]
    
    cnt = 0.0
    for j in range (1, len(a)):
        cnt += b.count(j)*(b.count(j)-1)/2
    print(int(cnt))

### FIXED CODE ###

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

num_list = [0]* (len(a)+1)

for i in range(len(a)):
#    num_list[i] = a.count(i)
    num_list[a[i]] += 1

total = 0

for j in range(len(num_list)):
    total += (num_list[j]* (num_list[j]-1))/2

#print(total)

for k in range(len(a)):
#    print(num_list[a[k]]) 
    print(int(total-(num_list[a[k]])+1))
"""
import math

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

cnt = flaot(0.0)

for i in range(1, len(a)+1):
    b = a[0:i-1]+a[i:len(a)]
    
    cnt = 0.0
    for j in range (1, len(a)):
        cnt += b.count(j)*(b.count(j)-1)/2
    print(int(cnt))
"""
### BUGGY CODE ###

N,K = map(int,input().split())
A = list(map(int, input().split()))
kake = []
sum = 1
for i in range(0,N-K+1):
  for j in range(K):
  	sum *= A[i+j]
  kake += [sum]
  sum = 1
for num in range(len(kake)-1):
  if kake[num] < kake[num+1]:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

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

for i in range(0,N-K):
  if A[i] < A[i+K]:
    print("Yes")
  else:
    print("No")
### BUGGY CODE ###

def good_or_bad(h, loads, H):
  squeezed_map = []

  for m in loads:
    if h+1 not in m:
      continue

    if H[m[0]-1] > H[h] or H[m[1]-1] > H[h] or H[m[0]-1] == H[m[1]-1]:
      # print(h)
      return False

  return True

def resolve():
  N, M = map(int, input().split(" "))
  H = [int(x) for x in input().split(" ")]

  AB = []
  for i in range(M):
    AB.append([int(x) for x in input().split(" ")])

  result = []
  for ab in AB:
    if ab not in result:
      result.append(ab)
  AB = result

  result = 0
  for h in range(len(H)):
    if good_or_bad(h, AB, H):
      result += 1

  print(result)

if __name__ == "__main__":
    resolve()

### FIXED CODE ###

def resolve():
  N, M = map(int, input().split(" "))
  H = [int(x) for x in input().split(" ")]

  AB = []
  for i in range(M):
    AB.append([int(x)-1 for x in input().split(" ")])

  result = [True] * N
  for ab in AB:
    if H[ab[0]] > H[ab[1]]:
      result[ab[1]] = False
      continue
    if H[ab[1]] > H[ab[0]]:
      result[ab[0]] = False
      continue
    if H[ab[1]] == H[ab[0]]:
      result[ab[0]] = False
      result[ab[1]] = False
      continue

  print(result.count(True))

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

import math
import bisect

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

alist.sort()
#print(alist)

flist=[False]*N
answer=0
for i in reversed(range(N)):
  if flist[i]:
    continue
  
  p1=alist[i]
  p2=2**math.ceil(math.log(p1+1,2))-p1
  #print(p1,p2)
  
  index1 = bisect.bisect_left(alist,p2)  
  index2 = bisect.bisect_right(alist,p2)  
  #print(index1,index2)
  for j in range(index1,index2):
    if j != i and not flist[j]:
      flist[i]=True
      flist[j]=True
      answer+=1
      break
  
#print(flist)    
print(answer)

### FIXED CODE ###

import bisect
N=int(input())
alist=list(map(int,input().split()))
alist.sort(reverse=True)

blist=[]
for a in alist:
  a2=a
  digit_a2=0
  while(a2>0):
    a2>>=1
    digit_a2+=1
  b=2**(digit_a2)-a
  blist.append(b)
#print(alist)
#print(blist)

dic_a={}
for a in alist:
  if a in dic_a:
    dic_a[a]+=1
  else:
    dic_a[a]=1

answer=0
for i in range(N):
  a=alist[i]
  b=blist[i]
  if a==b:
    if dic_a[a]>1:
      dic_a[a]-=2
      answer+=1
      #print(a,a)
  else:
    if dic_a[a]>0 and b in dic_a and dic_a[b]>0:
      dic_a[a]-=1
      dic_a[b]-=1
      answer+=1
      #print(a,b)
    
print(answer)