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

N,K,Q=map(int,input().split())
A=list(map(int,input().split()))
a=list(set(A))
a.sort()
ans=float("inf")
def condition(i,num):
    if i>a[num]:
        return False
    X=a[num]
    Y=A[i]
    data=[-1 for i in range(0,N)]
    for k in range(0,N):
        if Y>A[k]:
            data[k]=0
        elif A[k]>X:
            data[k]=1
        else:
            data[k]=2
    check=0
    stack=0
    count=0
    for k in range(0,N):
        if data[k]==1:
            stack+=1
        elif data[k]==2:
            stack+=1
            count+=1
        else:
            t=stack+1-K
            check+=max(min(t,count),0)
            stack=0
            count=0
    t=stack+1-K
    check+=max(min(t,count),0)
    return check>=Q

for i in range(0,N):
    start=0
    end=len(a)-1
    while end-start>1:
        test=(end+start)//2
        if condition(i,test):
            end=test
        else:
            start=test
    if condition(i,start):
        ans=min(ans,a[start]-A[i])
    elif condition(i,end):
        ans=min(ans,a[end]-A[i])
print(ans)

### FIXED CODE ###

N,K,Q=map(int,input().split())
A=list(map(int,input().split()))
a=list(set(A))
a.sort()
ans=float("inf")
def condition(i,num):
    if i>a[num]:
        return False
    X=a[num]
    Y=A[i]
    check=0
    stack=0
    count=0
    for k in range(0,N):
        if A[k]>X:
            stack+=1
        elif A[k]>=Y:
            stack+=1
            count+=1
        else:
            t=stack+1-K
            check+=max(min(t,count),0)
            stack=0
            count=0
    t=stack+1-K
    check+=max(min(t,count),0)
    return check>=Q

for i in range(0,N):
    start=0
    end=len(a)-1
    while end-start>1:
        test=(end+start)//2
        if condition(i,test):
            end=test
        else:
            start=test
    if condition(i,start):
        ans=min(ans,a[start]-A[i])
    elif condition(i,end):
        ans=min(ans,a[end]-A[i])
print(ans)
### BUGGY CODE ###

S = input()
Q = int(input())
I = 0
for i in range(Q):
    Query = input().split()
    if Query[0] == "1":
        I = I + 1
    else:
        if (int(Query[1]) + I) % 2 == 0:
            S = S + Query[2]
        else:
            S = Query[2] + S
if I % 2:
    S = S[::-1]
print(S)


### FIXED CODE ###

S = input()
Q = int(input())
I = 0
L = ''
R = ''
for i in range(Q):
    Query = input().split()
    if Query[0] == "1":
        I = I + 1
    else:
        if (int(Query[1]) + I) % 2 == 0:
            R = R + Query[2]
        else:
            L = L + Query[2]
L = L[::-1]
S = L + S + R

if I % 2:
    S = S[::-1]
print(S)
### BUGGY CODE ###

S=int(input())
a=[S]

while a[-1]!=8:
    if a[-1]%2==0:
        a.append(a[-1]//2)
    else:
        a.append(a[-1]*3+1)

else:
    print(len(a)+4)
    

### FIXED CODE ###

S=int(input())
count=1
for i in range(1000000):
    if S==8:
        print(count+4)
        break
    elif S==4:
        print(count+3)
        break
    elif S==2:
        print(count+3)
        break
    elif S==1:
        print(count+3)
        break
    elif S%2==0:
        S//=2
        count+=1
    else:
        S=S*3+1
        count+=1
### BUGGY CODE ###

#D
N=int(input())
ans=0
D={}
for x in range(1,10):
    for y in range(1,10):
        D[(x,y)]=0

for key in D.keys():
    x,y=key
    for i in range(1,N+1):
        a=int(str(i)[0])
        b=int(str(i)[-1])
        if x==a and y==b:
            D[key]+=1
for i in range(1,10):
    for j in range(1,10):
        ans+=D[(i,j)]*D[(j,i)]
print(ans)

### FIXED CODE ###

#D
N=int(input())
ans=0
D=[[0 for i in range(10)] for j in range(10)]

for i in range(1,10):
    for j in range(1,10):
        for k in range(1,N+1):
            if str(i)==str(k)[0] and str(j)==str(k)[-1]:
                D[i][j]+=1
for i in range(1,10):
    for j in range(1,10):
        ans+=D[i][j]*D[j][i]
print(ans)
### BUGGY CODE ###

N,K = map(int,input().split())
P = list(map(int,input().split()))
E = [0] * N
S = [0] * (N - K + 1)

for p in range(N):
  E[p] = (P[p] + 1) / 2

for i in range(N-K+1):
  S[i] = sum(E[i:i+K])
print(max(S))

### FIXED CODE ###

N,K = map(int,input().split())
P = list(map(int,input().split()))
E = [(p+1)/2 for p in P]
temp = sum(E[0:K])
S =  temp
for i in range(N-K):
  temp -= E[i]
  temp += E[i+K]
  if S < temp:
    S = temp  
print(S)
### BUGGY CODE ###

n,k=map(int,raw_input().split())
a=map(int,raw_input().split())

res = [(a.count(e),e) for e in set(a)]
div=max(0,len(res)-k)

resl=sorted(res,key=lambda x:x[0],reverse=True)
ans=0
while div>0:
    ans+=resl[-1][0]
    resl.pop()
    div-=1
print ans



### FIXED CODE ###

import heapq

n,k=map(int,raw_input().split())
a=map(int,raw_input().split())



d={}
for i in a:
    if i in d:
        d[i]+=1
    else:
        d[i]=1
l=d.values()
div=max(0,len(l)-k)
if div==0:
    print 0
    exit()


heapq.heapify(l)

ans=0
while div>0:
    ans+=heapq.heappop(l)
    div-=1
print ans
### BUGGY CODE ###

def corp(i):
    return i*(i-1)//2

N=int(input())
A=list(map(int,input().split()))
box=[0]*N
for i in A:
    box[i-1]+=1

for i in A:
    sum=0
    for j in range(N):
        if j==i:
            sum+=corp(box[j-1]-1)
        else:
            sum+=corp(box[j-1])
    print(sum)


### FIXED CODE ###

def corp(i):
    return i*(i-1)//2

N=int(input())
A=list(map(int,input().split()))
box=[0]*N
for i in A:
    box[i-1]+=1
sum=0
for i in box:
    if i != 1:
        sum+=corp(i)
for i in A:
    ans=sum
    if box[i-1] != 1:
        ans=ans-corp(box[i-1])+corp(box[i-1]-1)
    print(ans)
### BUGGY CODE ###

def resolve():
    n = int(input())
    s = input()
    rlist = []
    glist = []
    blist = []
    for i in range(n):
        if s[i] == "R":
            rlist.append(i)
        elif s[i] == "G":
            glist.append(i)
        else:
            blist.append(i)
    ans = 0
    for i in range(len(rlist)):
        r = rlist[i]
        for j in range(len(glist)):
            g = glist[j]
            for k in range(len(blist)):
                b = blist[k]
                count = sorted([r, g, b])
                if count[2]-count[1] != count[1]-count[0]:
                    ans += 1
    print(ans)
resolve()

### FIXED CODE ###

def resolve():
    n = int(input())
    s = input()
    rlist = []
    glist = []
    blist = []
    for i in range(n):
        if s[i] == "R":
            rlist.append(i)
        elif s[i] == "G":
            glist.append(i)
        else:
            blist.append(i)
    blist = set(blist)
    ans = 0
    for i in range(len(rlist)):

        for j in range(len(glist)):
            r = rlist[i]
            ng = 0
            g = glist[j]
            s = sorted([r, g])
            r = s[0]
            g = s[1]
            if (r-(g-r)) in blist:
                ng += 1
            if (g+(g-r)) in blist:
                ng += 1
            if (r+g) % 2 == 0 and (r+g)//2 in blist:
                ng += 1
            ans += len(blist)-ng
    print(ans)
resolve()
### BUGGY CODE ###

from bisect import bisect_left
from operator import itemgetter

N, Q = map(int, input().split(" "))
check_points = [tuple(map(int, input().split(" "))) for _ in range(N)]
querys = [int(input()) for _ in range(Q)]
time = {}
sorted_querys = sorted(querys)
check_points = sorted(check_points, key=itemgetter(2))
for q in querys:
    time[q] = -1
b_left = bisect_left

for line in check_points:
    s, f, x = line
    start = s-x
    end = f-x
    left = b_left(sorted_querys, start)
    right = b_left(sorted_querys, end)
    for q in sorted_querys[left:right]:
        if time[q] == -1:
            time[q] = x
    if len(sorted_querys) == 0:
        break
for q in querys:
    print(time[q])


### FIXED CODE ###

from bisect import bisect_left
from operator import itemgetter

N, Q = map(int, input().split(" "))
check_points = [tuple(map(int, input().split(" "))) for _ in range(N)]
querys = [int(input()) for _ in range(Q)]
time = [-1 for _ in range(Q)]
jump = [-1 for _ in range(Q)]
check_points = sorted(check_points, key=itemgetter(2))
b_left = bisect_left

for line in check_points:
    s, f, x = line
    start = s-x
    end = f-x
    left = b_left(querys, start)
    right = b_left(querys, end)
    while left < right:
        if time[left] == -1:
            time[left] = x
            jump[left] = right
            left += 1
        else:
            left = jump[left]

for t in time:
    print(t)
### BUGGY CODE ###

N, M = map(int, input().split())
CARDS = {i for i in range(1,N+1)}

for i in range(M):
    L, R = map(int, input().split())
    CARDS &= {card for card in range(L,R+1)}

print(len(CARDS))

### FIXED CODE ###

N, M = map(int, input().split())
Ls, Rs = set(), set()

for _ in range(M):
    L, R = map(int, input().split())
    Ls.add(L)
    Rs.add(R)

print(len([i for i in range(max(Ls), min(Rs)+1)]))
### BUGGY CODE ###

def main():
    s = list(input())
    n = len(s)
    dp = [[0 for _ in range(13)] for _ in range(n+1)]
    dp[0][0] = 1
    mod = 10**9+7
    for i in range(n):
        if s[i] != '?':
            for j in range(13):
                dp[i+1][(j*10+int(s[i]))%13] += dp[i][j]
                dp[i+1][(j*10+int(s[i]))%13] %= mod
        else:
            for j in range(10):
                for k in range(13):
                    dp[i+1][(k*10+j)%13] += dp[i][k]
                    dp[i+1][(k*10+j)%13] %= mod
    print(dp[n][5])

if __name__ == "__main__":
    main()

### FIXED CODE ###

mod = 10**9+7
def main():
    s = list(input())
    n = len(s)
    dp = [[0 for _ in range(13)] for _ in range(n+1)]
    dp[0][0] = 1
    for i in range(n):
        if s[i] != '?':
            s[i] = int(s[i])
            for k in range(13):
                index = (k*10+s[i])%13
                dp[i+1][index] += dp[i][k]
        else:
            for j in range(10):
                for k in range(13):
                    index = (k*10+j)%13
                    dp[i+1][index] += dp[i][k]
        for j in range(13):
            dp[i+1][j] %= mod
    print(dp[n][5])

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

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)


K = int(input())
sum = 0

for i in range(1, K+1):
    for j in range(1, K+1):
        for l in range(1, K+1):
            sum += gcd(i, gcd(j, l))

print(sum)

### FIXED CODE ###

import math

K = int(input())
sum = 0

for i in range(1, K+1):
    for j in range(1, K+1):
        for l in range(1, K+1):
            sum += math.gcd(i, math.gcd(j, l))

print(sum)
### BUGGY CODE ###

N=int(input())
A=list(input().split())

X=0
for i in range(N):
    X+=A.count(A[i])

if X==N:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

N=int(input())
A=list(map(int, input().split()))
 
if len(set(A))==len(A):
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().strip()

n=int(input())
xs=input()
#xk=list(map(int,list(xs)))
xj=xs.count("1")

x=int(xs,2)

for i in range(n-1,-1,-1):
    xi=x^(1<<i)
    pxi=xj
    if xs[n-1-i]=="0":
        pxi=pxi+1
    else:
        pxi=pxi-1
    if xi==0:
        print(0)
    else:
        xi=xi%pxi
        if xi==0:
            print(1)
        else:
            icnt=1
            while xi>0:
                icnt+=1
                xi=xi%(bin(xi).count("1"))
            print(icnt)


### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()

n=int(input())
xs=input()
xj=xs.count("1")

x=int(xs,2)
xip=x%(xj+1)
if xj!=1:
    xim=x%(xj-1)

for i in range(n-1,-1,-1):
    if xs[n-1-i]=="0":
        pxi=xj+1
        i2=pow(2,i,pxi)
        xi=(xip+i2)%pxi
    elif xj==1:
        print(0)
        continue
    else:
        pxi=xj-1
        i2=pow(2,i,pxi)
        xi=(xim-i2)%pxi
    xi=xi%pxi
    if xi==0:
        print(1)
        continue
    icnt=1
    while xi>0:
#        print("i",i,"xi",xi,"icnt",icnt)
        icnt+=1
        xi=xi%(bin(xi).count("1"))
    print(icnt)
### BUGGY CODE ###

from collections import deque


N = int(input())
branch = [[0] + list(map(lambda x: int(x) - 1, input().split())) for _ in range(N - 1)]
branch_color = [0] * (N - 1)
vertex = [False] * N


def bfs():
    max_color = 0
    q = deque()
    v = 0
    bc = 0
    q.append((v, bc))

    while len(q):
        v, bc = q.popleft()
        vertex[v] = True
        b_list = [c for c in branch if v in c[1:]]

        color = 1
        for c in b_list:
            if color == bc:
                color += 1
            if (c[0] == 0):
                c[0] = color
                color += 1

        max_color = max(max_color, color - 1)

        for c in b_list:
            nv = c[1] if c[2] == v else c[2]
            if vertex[nv] is False:
                q.append((nv, c[0]))

    return max_color


print(bfs())
for b in branch:
    print(b[0])


### FIXED CODE ###

import sys


sys.setrecursionlimit(10 ** 6)

N = int(input())
edge = [[] for _ in range(N)]
for i in range(N - 1):
    a, b = map(int, input().split())
    edge[a - 1].append((b - 1, i))
    edge[b - 1].append((a - 1, i))
ec = [0] * (N - 1)


def dfs(node, pc):
    color = 1

    for to, idx in edge[node]:
        if ec[idx] == 0:
            if color == pc:
                color += 1
            ec[idx] = color

            dfs(to, color)
            color += 1


dfs(0, -1)
print(max(ec))
for c in ec:
    print(c)
### BUGGY CODE ###

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

passcard = []
for c in range(l[0][1] - l[0][0]+1):
    passcard.append(l[0][0]+c)

for tt in range(n[1]):
    t = n[1] - tt -1
    for i in range(len(passcard)):
        if not(l[t][0] <= passcard[i] <= l[t][1]):
            passcard[i] = 0
        else:
            passcard[i] = passcard[i]

    passcard = [i for i in passcard if i!=0]
            
out = [i for i in passcard if i!=0]
print(len(out))

### FIXED CODE ###

n = list(map(int,input().split()))
l = [list(map(int,input().split())) for i in range(n[1])]
minp = l[0][0]
maxp = l[0][1]
for t in range(n[1]):
    minp = max(minp,l[t][0])
    maxp = min(maxp,l[t][1])
print(max(0,maxp-minp+1))
### BUGGY CODE ###

N = int(input())
l = []
for i in range(N):
  l.append(input())
s = set(l)
ss = list(s)
ss.sort()
w = []
for i in range(len(ss)):
  w.append(l.count(ss[i]))
for i in range(len(w)):
  if max(w) == w[i]:
    print(ss[i])

### FIXED CODE ###

from collections import Counter
n = int(input())
l = []
for i in range(n):
  l.append(input())
c = Counter(l)
t = c.most_common()
x = 0
ans = []
for k,v in t:
  if x <= v:
    ans.append(k)
    x = v
ans.sort()
for i in range(len(ans)):
  print(ans[i])
### BUGGY CODE ###

import sys
import itertools
input = sys.stdin.readline
inf = 200000000
n, m, r = map(int, input().split())
rs = list(map(int, input().split()))
n1 = n + 1
d = [inf] * (n1 * n1)
for i in range(n1):
    d[i * n1 + i] = 0
for i in range(m):
    a, b, c = map(int, input().split())
    d[a * n1 + b] = d[b * n1 + a] = c
for k, i, j in itertools.product(range(1, n1), repeat=3):
    d[i * n1 + j] = d[j * n1 + i] = min(
        d[i * n1 + j],
        d[i * n1 + k] + d[k * n1 + j])
s = inf
for q in itertools.permutations(range(r)):
    t = 0
    for i in range(r-1):
        t += d[rs[q[i]] * n1 + rs[q[i+1]]]
    if s > t:
        s = t
print(s)


### FIXED CODE ###

from itertools import product, permutations


def warshall_floyd(d):
    # d        : nxn adjacent matrix
    for k, i, j in product(range(n), repeat=3):
        if d[i][j] > d[i][k] + d[k][j]:
            d[i][j] = d[i][k] + d[k][j]


INF = float("inf")
n, m, r = map(int, input().split())
r_list = list(map(lambda x: int(x) - 1, input().split()))
d = [[INF] * n for _ in range(n)]
for i in range(n):
    d[i][i] = 0
for i in range(m):
    a, b, c = map(int, input().split())
    a, b = a - 1, b - 1
    d[a][b] = d[b][a] = c
warshall_floyd(d)

ans = float("inf")
for np in permutations(r_list):
    cand = sum([d[np[i]][np[i + 1]] for i in range(r - 1)])
    ans = min(ans, cand)

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

# ABC153e


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

    h, n = map(int, input().split())
    maho = []
    for _ in range(n):
        maho.append(list(map(int, input().split())))

    # dp[i][j]=i番目までの魔法でモンスターの体力をj減らすためにつかう魔力の最小値
    # dp[i][j]=min(dp[i-1][j],dp[i][j-maho[i][0]])+maho[i][1]

    dp = [[10 ** 12] * (h + 1) for _ in range(n+1)]
    dp[0][0] = 0
    for i in range(n):
        for j in range(h + 1):
            if j == 0:
                dp[i + 1][0] = 0
            dp[i + 1][j] = min(dp[i][j],
                               dp[i + 1][max(0, j - maho[i][0])] + maho[i][1])
    print(dp[n][h])


if __name__ == '__main__':
    main()


### FIXED CODE ###

# ABC153e


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

    h, n = map(int, input().split())
    maho = []
    for _ in range(n):
        maho.append(list(map(int, input().split())))

    # dp[i][j]=i番目までの魔法でモンスターの体力をj減らすためにつかう魔力の最小値
    # dp[i][j]=min(dp[i-1][j],dp[i][j-maho[i][0]])+maho[i][1]

    dp = [[10 ** 12] * (h + 1) for _ in range(3)]
    dp[0][0] = 0
    for i in range(n):
        for j in range(h + 1):
            if j == 0:
                dp[(i + 1) % 3][0] = 0
            dp[(i + 1) % 3][j] = min(dp[i % 3][j],
                                     dp[(i + 1) % 3][max(0, j - maho[i][0])] + maho[i][1])
    print(dp[n % 3][h])


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

# coding=utf-8

line = input().split(" ")
N = int(line[0])
M = int(line[1])

if M==0:
    print("Yes")
    exit()

l = []
for _ in range(M):
    line = input().split(" ")
    l.append((
        int(line[0])-1
        ,int(line[1])-1
        ,int(line[2])
    ))
l.sort()
o = l[0][0]
for i in range(M):
    l[i] = (
        l[i][0]-o
        ,l[i][1]-o
        ,l[i][2]
    )

nl = [-1 for x in range(N)]
nl[0] = 0

flag = True
while flag:
    flag = False
    ll = []
    for c in l:
        if nl[c[0]]>=0 and nl[c[1]]==-1:
            nl[c[1]] = nl[c[0]]+c[2]
        elif nl[c[0]]==-1 and nl[c[1]]>=0:
            nl[c[0]] = nl[c[1]]-c[2]
        elif nl[c[0]]>=0 and nl[c[1]]>=0:
            if nl[c[1]]-nl[c[0]]==c[2]:
                pass
            else:
                print("No")
                exit()
        else:
            ll.append(c)
            flag = True
    l = ll.copy()

print("Yes")


### FIXED CODE ###

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

class WeightedUnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)
        # 根への距離を管理
        self.weight = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            y = self.find(self.par[x])
            # 親への重みを追加しながら根まで走査
            self.weight[x] += self.weight[self.par[x]]
            self.par[x] = y
            return y

    # 併合
    def unite(self, x, y, w):
        rx = self.find(x)
        ry = self.find(y)
        # xの木の高さ < yの木の高さ
        if self.rank[rx] < self.rank[ry]:
            self.par[rx] = ry
            self.weight[rx] = w - self.weight[x] + self.weight[y]
        # xの木の高さ ≧ yの木の高さ
        else:
            self.par[ry] = rx
            self.weight[ry] = -w - self.weight[y] + self.weight[x]
            # 木の高さが同じだった場合の処理
            if self.rank[rx] == self.rank[ry]:
                self.rank[rx] += 1

    # 同じ集合に属するか
    def same(self, x, y):
        return self.find(x) == self.find(y)

    # xからyへのコスト
    def diff(self, x, y):
        return self.weight[x] - self.weight[y]

n,m = map(int, input().split())
uf = WeightedUnionFind(n)
for _ in range(m):
    l,r,d = map(int, input().split())
    if uf.same(l,r):
        if uf.diff(l,r) != d:
            print("No")
            exit()
    else:
        uf.unite(l,r,d)

print("Yes")
### BUGGY CODE ###

A = input()
B = input()
C = input()

def match(v,w):
    if(v != '?' and w != '?' and v != w):
        return 0
    else:
        return 1

def middle(x,y,z):
    X = [x,y,z]
    X.sort()
    return(X[1])


def milen(a,b,c):
    aa = len(a)
    bb = len(b)
    cc = len(c)

    minlen = aa + bb + cc
    s = '?'*(bb+cc) + a + '?'*(bb+cc)
    for i in range(-bb,aa+1):
        start = min(0,i)
        end = max(aa,i+bb)
        t = '?'*(bb+cc+i) + b + '?'*(aa+cc-i)
        for j in range(start-cc,end+1):
            sta = min(start,j)
            en = max(end,j+cc)
            u = '?'*(bb+cc+j) + c + '?'*(aa+bb-j)
            flag = 1
            for k in range(middle(0,i,j)+bb+cc,middle(aa,i+bb,j+cc)+bb+cc):
                if(match(s[k],u[k]) == 0):
                    flag = 0
                    break
                if(match(t[k],u[k]) == 0):
                    flag = 0
                    break
                if(match(s[k],t[k]) == 0):
                    flag = 0
                    break
            if(flag == 1):
                minlen = min(minlen,en-sta)
    return minlen

print(min(milen(A,B,C),milen(A,C,B)))

### FIXED CODE ###

a = input()
b = input()
c = input()

aa = len(a)
bb = len(b)
cc = len(c)

lensum = aa + bb + cc # 文字列の長さの最大値
ab = [0]*(lensum+cc+1) # 相対的位置に対して合わさるかどうかを記録
ac = [0]*(lensum+bb+1)
bc = [0]*(lensum+aa+1)

def match(v,w): # 2つの文字を合わせられるかどうかを調べる
    if(v != '?' and w != '?' and v != w):
        return 0
    else:
        return 1

def match2(A,B,k): # 2つの文字列とその相対的位置に対して合わさるかチェック
    AA = len(A)
    BB = len(B)
    if(k>=AA):
        return 1
    elif(k<-BB):
        return 1
    else:
        flg = 1
        st = max(0,k)
        la = min(AA,BB+k)
        for i in range(st,la):
            if(match(A[i],B[i-k])==0):
                flg = 0
                break
        return flg

#ab,ac,bcに対して計算する
for i in range(lensum+cc+1):
    ab[i] = match2(a,b,i-bb-cc)
for i in range(lensum+bb+1):
    ac[i] = match2(a,c,i-bb-cc)
for i in range(lensum+aa+1):
    bc[i] = match2(b,c,i-aa-cc)

def milen(a,b,c):
    minlen = lensum # 文字列の長さの最大値
    for i in range(-bb-cc,aa+cc+1): # iが文字列Bの開始位置
        for j in range(-bb-cc,aa+bb+1): # jが文字列Cの開始位置
            if(ab[i+bb+cc] == 0): 
                continue
            elif(ac[j+bb+cc] == 0):
                continue
            elif(j-i+aa+cc < 0 or j-i+aa+cc >= lensum+aa+1): #BとCが離れすぎている場合を除く
                continue  
            elif(bc[j-i+aa+cc] == 0):
                continue   
            else:
                sta = min(0,i,j) #文字列の中で一番左にある開始位置
                en = max(aa,i+bb,j+cc) #文字列の中で一番右にある終了位置
                minlen = min(minlen,en-sta) #更新
    return minlen

print(milen(a,b,c))
### BUGGY CODE ###

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

### FIXED CODE ###

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

import sys

nbs = list(sorted(map(int, list(sys.stdin)[1].strip().split())))
used = set()
count = 0

for k in reversed(range(1, 31)):
    p = 1 << k
    j = len(nbs) - 1
    for i, a in enumerate(nbs):
        if i not in used:
            while j > i and (nbs[j] > p - a or j in used):
                j -= 1
            if j <= i:
                break
            if nbs[j] == p - a:
                used.add(i)
                used.add(j)
                count += 1

print(count)

### FIXED CODE ###

input()
nbs = map(int, input().split())

answer = 0
count = {}

for nb in nbs:
    count[nb] = count.get(nb, 0) + 1

for nb in sorted(count.keys(), reverse=True):
    searching = (1 << nb.bit_length()) - nb
    nb_count = count[nb]
    sr_count = count.get(searching, 0)
    if sr_count:
        if nb == searching:
            increment = nb_count // 2
        else:
            increment = nb_count if nb_count < sr_count else sr_count
            count[searching] -= increment
        answer += increment

print(answer)