Harryxun/stf_run huggingface dataset:
n = int(input())
a_l = list(map(int, input().split()))
a_l.sort()
b_l = list()

length = len(a_l)
k = 0
for i in range(length):
  if a_l[i] < 0:
    k = i
  else:
    break

b_l = a_l[:k+1]
a_l = a_l[k+1:]
fu = len(b_l)
sei = len(a_l)
ans_l = list()
ans_ll = list()
if sei > fu:
  sa = sei-fu-1
  ans_ll+= a_l[:sa]
  ans_ll.append(a_l[-1])
  for i in range(fu):
    ans_l.append([b_l[i], a_l[-i-2]])
    ans_ll.append(b_l[i]-a_l[-i-2])
  ans_ll.sort()
  lent = len(ans_ll)
  for i in range(lent-1):
    ans_l.append([ans_ll[-1], ans_ll[i]])
    ans_ll[-1] = ans_ll[-1]-ans_ll[i]
elif sei < fu:
  sa = fu-sei+1
  ans_ll += b_l[:sa]
  ans_ll.append(a_l[-1])
  for i in range(sei-1):
    ans_l.append([b_l[i], a_l[-i-2]])
    ans_ll.append(b_l[i]-a_l[-i-2])
  ans_ll.sort()
  lent = len(ans_ll)  
  for i in range(lent-1):
    ans_l.append([ans_ll[-1], ans_ll[i]])
    ans_ll[-1] = ans_ll[-1]-ans_ll[i]
else:
  for i in range(sei):
    if i == 0:
      ans_l.append([a_l[-i-1], b_l[i]])
      ans_ll.append(a_l[-i-1]-b_l[i])
    else:
      ans_l.append([b_l[i], a_l[-i-1]])
      ans_ll.append(b_l[i]-a_l[-i-1])
  ans_ll.sort()
  lent = len(ans_ll)  
  for i in range(lent-1):
    ans_l.append([ans_ll[-1], ans_ll[i]])
    ans_ll[-1] = ans_ll[-1]-ans_ll[i]
    
ans_length = len(ans_l)
print(ans_ll[-1])
for i in range(ans_length):
  a = ans_l[i][0]
  b = ans_l[i][1]
  print(a, b)
  
    
                 
    


### FIXED CODE ###

n, k = map(int, input().split())
ans = n%k
print(ans)
N, X = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]
D = 0
count = 0
answer = 1

while D <= X:
  D += L[count]
  count += 1
  answer += 1

print(answer - 1)

### FIXED CODE ###

# W, H, x, y = [int(i) for i in input().split()]
N, X = [int(i) for i in input().split()]
L = [int(i) for i in input().split()]
D = 0
count = 0
answer = 1

while D <= X:
  if count + 1 > len(L):
    print(N+1)
    exit()
  D += L[count]
  count += 1
  answer += 1

print(answer - 1)
iroha = input()
iroha = iroha.split(" ")
iroha = sorted(iroha)
if iroha = ["5", "5", "7"]:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

iroha = input()
iroha = iroha.split(" ")
iroha = sorted(iroha)
if iroha == ["5", "5", "7"]:
  print("YES")
else:
  print("NO")
# -*- coding: utf-8 -*-

n = input()

N = 10

child_data = [[1]*len(n)]
for j in range(1, len(n)+1):
    child_fin = [0]*len(n)
    for i in range(len(n)):
        if n[i] == "L":
            child_fin[i-1] += child_data[j-1][i]
        else:
            child_fin[i+1] += child_data[j-1][i]
    child_data.append(child_fin)
    if child_fin in child_data[:-1]:
        child_last = child_data[-(j%2+1)]
        break

output = " ".join(map(str, child_last))
print(output)

### FIXED CODE ###

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

a, b, c = map(int, input().split())

print(max(c-a+b, 0))
H, N = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    H = H -A[i]
if H =< 0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

H = list(map(int, input().split()))
A = list(map(int, input().split()))
for i in range(H[1]):
    H[0]= H[0] -A[i]
if H[0] <= 0:
    print('Yes')
else:
    print('No')
import math

n, X = map(int, input().split())
x = list(map(int, input().split()))

xx = []

for i in range(n):
    xx.append(abs(x[i]-X))

if n == 1:
    print(xx[0])
else:
    xg = xx[0]
    for i in range(1,n):
        xg = math.gcd(xg,xx[i])
    print(xg)


### FIXED CODE ###

import fractions

n, X = map(int, input().split())
x = list(map(int, input().split()))

xx = []

for i in range(n):
    xx.append(abs(x[i]-X))

if n == 1:
    print(xx[0])
else:
    xg = xx[0]
    for i in range(1,n):
        xg = fractions.gcd(xg,xx[i])
    print(xg)
N = int(input())
A = list(map(int,input().split()))

MIN,MAX = 10**7,-10**7
ans = []
for i in range(N):
    if MIN > A[i]:
        MIN =A[i]
        min_i = i
    if MAX < A[i]:
        MAX = A[i]
        max_i = i

if abs(MIN) <= abs(MAX):
    for i in range(N):
        if A[i] < 0:
            A[i] += MAX
            ans.append([max_i+1,i+1])
    # print(A)

    for i in range(N-1):
        if A[i] > A[i+1]:
            A[i+1] += A[i]
            ans.append([i+1,i+2])

else:
    for i in range(N):
        if A[i] > 0:
            A[i] += MIN
            ans.append(min_i,i+1)
    # print(A)

    for i in range(N-1,0,-1):
        if A[i] < A[i-1]:
            A[i-1] += A[i]
            ans.append([i+1,i])

print(len(ans))
for a in ans:
    print(*a)



### FIXED CODE ###

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

MIN,MAX = 10**7,-10**7
ans = []
for i in range(N):
    if MIN > A[i]:
        MIN =A[i]
        min_i = i
    if MAX < A[i]:
        MAX = A[i]
        max_i = i

if abs(MIN) <= abs(MAX):
    for i in range(N):
        if A[i] < 0:
            A[i] += MAX
            ans.append([max_i+1,i+1])
    # print(A)

    for i in range(N-1):
        if A[i] > A[i+1]:
            A[i+1] += A[i]
            ans.append([i+1,i+2])

else:
    for i in range(N):
        if A[i] > 0:
            A[i] += MIN
            ans.append([min_i+1,i+1])
    # print(A)

    for i in range(N-1,0,-1):
        if A[i] < A[i-1]:
            A[i-1] += A[i]
            ans.append([i+1,i])
print(len(ans))
for a in ans:
    print(*a)
import itertools
N, M = map(int, input().split())
br = set(tuple(map(int, input().split())) for i in range(M))

member = [i+1 for i in range(N)]
#print(member)
ans = 1
for i in range(1, N+1):
    for j in itertools.combinations(member,i):
        k = set(itertools.combinations(j,2))
        #print(k)
        #print(br)
        #print(k <= br)
        if((k <= br)and(i>ans)):
            ans = i
print(ans)
            


    


### FIXED CODE ###

def H(h, x, y, cx, cy):
    return h + abs(x-cx) + abs(y-cy)
def Hr(h, x, y, cx, cy):
    return max(h-abs(x-cx)-abs(y-cy),0)


N = int(input())
x = [list(map(int, input().split())) for i in range(N)]
for cx in range(0, 101):
    for cy in range(0, 101):
        judge = True
        m = [l for l in range(N) if x[l][2]!=0][0]
        H0 = H(x[m][2], x[m][0], x[m][1], cx, cy)
        for n in range(len(x)):
            Hn = H(x[n][2], x[n][0], x[n][1], cx, cy)
            #print(Hn)
            if(x[n][2] != 0):
                if(Hn == H0):
                    judge = judge and True
                else:
                    judge = judge and False
        if(judge):
            for n in range(len(x)):
                if(x[n][2] == 0):
                    Hm = Hr(H0, x[n][0], x[n][1], cx, cy)
                    if(Hm == 0):
                        judge = judge and True
                    else:
                        judge = judge and False
                
            if(judge):
                print(cx, cy, H0)
n = int(input())
ten = []
notten = []
for _ in range(n):
  s = int(input())
  if s % 10:
    notten.append(s)
  else:
    ten.append(s)
ans = sum(notten) + sum(ten)
if sum(notten) % 10 == 0:
  print(ans - min(notten))
elif ans % 10 == 0:
  print(0)
else:
  print(ans)
  

### FIXED CODE ###

n = int(input())
ten = []
notten = []
for _ in range(n):
  s = int(input())
  if s % 10:
    notten.append(s)
  else:
    ten.append(s)
ans = sum(notten) + sum(ten)
if notten and sum(notten) % 10 == 0:
  print(ans - min(notten))
elif ans % 10 == 0:
  print(0)
else:
  print(ans)
# coding: utf-8
import numpy as np

card = np.array([list(map(int, input().split())) for _ in range(3)])
n = int(input())

for _ in range(n):
    num = int(input())
    if num in card:
        pos = tuple(nd[0] for nd in np.where(card == num))
        card[pos[0], pos[1]] = 0

f = 0

for i in range(3):
    if sum(card[i,:]) == 0 or sum(card[:,i]) == 0:
        f = 1
    if card[0,0]+card[1,1]+card[2,2] == 0 or card[2,0]+card[1,1]+card[2,0] == 0:
        f = 1

if f:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

# coding: utf-8
import numpy as np

card = np.array([list(map(int, input().split())) for _ in range(3)])
n = int(input())

for _ in range(n):
    num = int(input())
    if num in card:
        pos = tuple(nd[0] for nd in np.where(card == num))
        card[pos[0], pos[1]] = 0

f = 0

for i in range(3):
    if sum(card[i,:]) == 0 or sum(card[:,i]) == 0:
        f = 1
    if card[0,0]+card[1,1]+card[2,2] == 0 or card[2,0]+card[1,1]+card[2,0] == 0:
        f = 1

if f:
    print('Yes')
else:
    print('No')
n = int(input())
li_a = list(map(int, input().split()))
li_b = list(map(int, input().split()))
li_c = list(map(int, input().split()))
ans = 0
for i in range(n):
  ans += li_b[li[i]]
  if i-1 >= 0:
      if li_a[i] == li_a[i-1]:
        ans += li_c[i-1]
print(ans)

### FIXED CODE ###

n = int(input())
aaa = list(map(int, input().split()))
li_a = []
for i in aaa:
  i -= 1
  li_a.append(i)
li_b = list(map(int, input().split()))
li_c = list(map(int, input().split()))
ans = 0
for i in range(n):
  ans += li_b[li_a[i]]
  if i-1 >= 0:
      if li_a[i] == li_a[i-1]+1:
        ans += li_c[li_a[i-1]]
print(ans)
import datetime

weekdays = [
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday",
]

while True:
  m, d = map(int, raw_input().strip().split(" "))
  print weekdays[datetime.date(2004, m, d).weekday()]

### FIXED CODE ###

import datetime

weekdays = [
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday",
]

while True:
  m, d = map(int, raw_input().strip().split(" "))
  if m == 0:
    break
  print weekdays[datetime.date(2004, m, d).weekday()]
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;

signed main() {
    int n, a, b;
    cin >> n >> a >> b;
    double v[n];
    map<double, int, greater<double>> mp;
    rep (i, 0, n) {
        cin >> v[i];
        mp[v[i]]++;
    }
    int cnt = 0;
    double sum = 0;
    ll ans = 1;
    double ave = 0;
    for (auto p : mp) {
        if (cnt + p.second < a) {
            sum += p.second * p.first;
            cnt += p.second;
        } else if (a <= cnt + p.second) {
            if (cnt == 0) {
                ans=0;
                rep(k,A,min(B,p.second)+1){
                    ll tmp=1;
                    rep (i, 1, p.second + 1) tmp *= i;
                    rep (i, 1, k + 1) tmp /= i;
                    rep (i, 1, p.second - k + 1) tmp /= i;
                    ans+=tmp;
                }
                ave = p.first;

            } else {
                int cnt2 = a - cnt;
                rep (i, 1, p.second + 1) ans *= i;
                rep (i, 1, cnt2 + 1) ans /= i;
                rep (i, 1, p.second - cnt2 + 1) ans /= i;
                ave = (sum + cnt2 * p.first) / a;
            }
            break;
        }
    }
    cout << fixed << setprecision (15) << ave << "\n" << ans << "\n";
}


### FIXED CODE ###

from collections import Counter
from collections import Counter
N, A, B = (list)(map(int, input().split()))
v = (list)(map(int, input().split()))

v = sorted(v, reverse=True)

sel_list = v[:A]
max_ave = sum(sel_list)/A
print(max_ave)

c = Counter(v)


def comb(n, r):
    r = min(r, n-r)
    ret = 1
    for i in range(r):
        ret *= (n-i)/(i+1)
    return ret


def ave_n(n):
    sel_list = v[:n]
    ave = sum(sel_list)/i
    if ave != max_ave:
        return 0
    last = sel_list[-1]
    use_last = sel_list.count(last)
    return comb(c[last], use_last)


ans = 0
for i in range(A, B+1):
    ret = ave_n(i)
    if ret == 0:
        break
    else:
        ans += ret
print((int)(ans))
n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
  
s = sum(t)
for j in range(max(n, m)):
  print(s - t[p[j]] + x[j])

### FIXED CODE ###

n = int(input())
t = list(map(int, input().split()))
m = int(input())
p = []
x = []
for i in range(m):
  q, y = map(int, input().split())
  p.append(q)
  x.append(y)
  
s = sum(t)
for j in range(m):
  print(s - t[p[j]-1] + x[j])
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,m=mii()
s=ii()
t=ii()

p=gcd(s,t)
if p!=s and p!=t and s[0]==p[0]:
    print(p)
else:
    print(-1)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,m=mii()
s=ss()
t=ss()
if len(s) < len(t):
    s,t=t,s
    n,m=m,n

p=n*m//gcd(n,m)
q=gcd(n,m)
if s[0]==t[0]:

    x,y=n//gcd(n,m),m//gcd(n,m)
    cnt=1

    for i in range(gcd(n,m)-1):
        if s[i*x]==t[i*y]:
            cnt+=1
    if cnt==q:
        print(p)
    else:
        print(-1)

else:
    print(-1)
#print(cnt,y)
n = int(input())
a = list(map(int, input().split()))
prod = math.prod(a, start=1)
if prod > 10**18:
  print(-1)
else :
  print(prod)

### FIXED CODE ###

n = int(input())
a =list(map(int, input().split()))
if 0 in a:
  print(0)
else :
  prod = 1
  for x in a:
    prod *= x
    if prod:
      if prod > 10**18:
        print(-1)
        break
    else :
      print(0)
      break
  else :
    print(prod)
n,k = map(int,input().split())
lis_a = list(map(int, input().split()))
mod = 1000000007
ans = 0
temp = 0
for i in range(len(lis_a)-1):
    for j in range(len(lis_a)):
        if(lis_a[i] > lis_a[j]):
            temp += 1
ans = (k*(temp+temp*k)//2) % mod
    
print(ans)

### FIXED CODE ###

m,d = map(int,input().split(" "))
ans = 0
for i in range(2,m+1):
    for j in range(2,d+1):
        if((j//10) * (j%10) == i and j//10 != 1 and j%10 != 1):
            ans += 1
print(ans)
import bisect
import array
 
n, m = map(int, input().split())
a = map(int, input().split())
a = array.array("L", sorted(list(a)))
for _ in range(m):  # O(m*n)
    max_num = a.pop()  # O(1)
    index = bisect.insert(a, max_num // 2)  # O(log n)
print(sum(a))

### FIXED CODE ###

class heap():
    def __init__(self, maxcom=True):
        if maxcom:
            self.compare = lambda x, y: x > y
        else:
            self.compare = lambda x, y: x < y

    def heappush(self, x, heap):
        heap.append(x)
        length = len(heap)
        pointer = length
        while True:
            if pointer == 1:
                break
            if self.compare(heap[pointer - 1], heap[(pointer >> 1) - 1]):
                heap[pointer - 1], heap[(pointer >> 1) - 1] = heap[(pointer >> 1) - 1], heap[pointer - 1]
                pointer = pointer >> 1
            else:
                break

    def heapreplace(self, function, heap):
        heap[0] = function(heap[0])
        pointer = 1
        length = len(heap)
        while True:
            if (pointer << 1) > length:
                break
            elif (pointer << 1) + 1 > length :
                if self.compare(heap[(pointer << 1) - 1], heap[pointer - 1]):
                    heap[(pointer << 1) - 1], heap[pointer - 1] = heap[pointer - 1], heap[(pointer << 1) - 1]
                else:
                    break
            else:
                if self.compare(heap[(pointer << 1) - 1], heap[pointer << 1]):
                    next_pointer = pointer << 1
                else:
                    next_pointer = (pointer << 1) + 1
                if self.compare(heap[next_pointer - 1], heap[pointer - 1]):
                    heap[next_pointer - 1], heap[pointer - 1] = heap[pointer - 1], heap[next_pointer - 1]
                    pointer=next_pointer
                else:
                    break


n, m = map(int, input().split())
a = map(int, input().split())
heapq = []
heapc=heap(True)
for i in a:
    heapc.heappush(i,heapq)
for _ in range(m):
    heapc.heapreplace(lambda x:x>>1,heapq)
print(sum(heapq))
def main():
	all,rolls=map(int,input().split())
	List=list(map(int,input().split()))

	sum = 0
	sumList =[]

	for i in range(all - rolls + 1):
		sum = 0
		for j in range(rolls):
			sum = sum + (List[i + j] + 1) / 2
		sumList.append(sum)

	sumList.sort(reverse=True)
	print(sumList[0])

if __name__ == '__main__':
	main()

### FIXED CODE ###

a,b=input().split()
c,d=map(int,input().split())
e=input()

if a==e:
	c = c - 1
else:
	d = d - 1

print(c,d)
import itertools

def chkTrg(a,b,c):
    if (a + b > c and b + c > a and c + a > b) and (a != b and b != c and c != a):
        return True
    else:
        return False

N = int(input())
bars = [int(i) for i in input().split(" ")]

cnt = 0

for bar in itertools.combinations(bars, 3):
    if chkTrg(bar[0],bar[1],bar[2]):
        cnt += 1

print(cnt)

### FIXED CODE ###

S = list(input())
cnt = 0
maxCnt = 0

for i in range(3):
    if S[i] == "R":
        cnt += 1
    else:
        cnt = 0
    if maxCnt < cnt:
        maxCnt = cnt

print(maxCnt)
for x in range(k + 1):
    for y in range(k + 1):
        if x + y > s:
            break
        for z in range(k + 1):
            count += (x + y + z == s)

print(count)


### FIXED CODE ###

k, s = map(int, input().rstrip("\n").split())
count = 0

for x in range(k + 1):
    for y in range(k + 1):
        if x + y > s:
            x = k + 1
            y = k + 1
            continue
        count += (s <= x + y + k)

print(count)
N=int(input())
AB=[list(map(int,input().split())) for _ in range(N)]

dist=[[0]*N in range(N)]
for i in range(N):
  for j in range(N):
    dist[i][j]=((AB[i][0]-AB[j][0])**2+(AB[i][1]-AB[j][1])**2)**0.5
    
ans=0
def go(town,rest):
  for i in len(rest):
    nrest=rest[:]
    ntown=nrest.pop(i)
    ans+=dist[town][ntown]
    if len(rest)==0:
      return
    go(ntown,nrest)
    
print(ans)


### FIXED CODE ###

N=int(input())
AB=[list(map(int,input().split())) for _ in range(N)]

dist=[[0]*N for _ in range(N)]
ans=0
for i in range(N):
  for j in range(N):
    if i==j:
      continue
    ans+=((AB[i][0]-AB[j][0])**2+(AB[i][1]-AB[j][1])**2)**0.5
ans/=N
print(ans)
n, m = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for i in range(m)]

if m % 2 == 1:
    print(-1)
    exit()

E = [[] for i in range(n + 1)]
used_e = [False] * m
ans = []

for i, (a, b) in enumerate(A):
    E[a].append((b, i))
    E[b].append((a, i))

used = [False] * (n + 1)

def dfs(v):
    if used[v]:
        return
    used[v] = True
    cnt = 0

    for to, i in E[v]:
        dfs(to)
        if not used_e[i]:
            cnt += 1

    if cnt % 2 == 1:
        cnt -= 1

    for to, i in E[v]:
        if not used_e[i] and cnt > 0:
            ans.append((v, to))
            used_e[i] = True

dfs(1)

for a in ans:
    print(*a)

### FIXED CODE ###

from sys import setrecursionlimit
setrecursionlimit(10 ** 8)

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

if m % 2 == 1:
    print(-1)
    exit()

E = [[] for i in range(n + 1)]
used_e = [False] * m
ans = []

for i, (a, b) in enumerate(A):
    E[a].append((b, i))
    E[b].append((a, i))

used = [False] * (n + 1)

def dfs(prev, v):
    if used[v]:
        return
    used[v] = True
    cnt = 0

    for to, i in E[v]:
        dfs(v, to)
        if not used_e[i]:
            cnt += 1

    for to, i in E[v]:
        if cnt % 2 == 1 and to == prev:
            continue
        if not used_e[i]:
            ans.append((v, to))
            used_e[i] = True

dfs(0, 1)

for a in ans:
    print(*a)
import bisect
def reversed_num(num):
  num_len=len(bin(num))-2
  f=2**num_len-1
  return num^f
n=int(input())
number=list(map(int,input().split()))
number.sort()
count=0
while len(number)>0:
  x=reversed_num(number.pop())+1
  if number[bisect.bisect_left(number,x)] ==x:
    number.pop(bisect.bisect_left(number,x))
    count+=1
print(count)

### FIXED CODE ###

import bisect
def reversed_num(num):
  num_len=len(bin(num))-2
  f=2**num_len-1
  return num^f
n=int(input())
number=list(map(int,input().split()))
number.sort()
count=0
while len(number)>0:
  k=number.pop()
  if len(number)==0:
    break
  if k==int(k):
    x=reversed_num(k)+1
    y=bisect.bisect_left(number,x)
    if x>number[-1]:
      y-=1
    if number[y] ==x:
      number[y]-=0.5
      count+=1
print(count)
a = input()
b = len(a)
print(a[0] + str(b) + a[b])

### FIXED CODE ###

a = input()
b = len(a)
print(a[0] + str(b-2) + a[b-1])
a  = int(input())
if a == 3:
    a1, a2, a3 = map(int, input().split())
    b1, b2, b3 = map(int, input().split())
    print(3)
elif a == 8:
    a1, a2, a3, a4, a5, a6, a7, a8 = map(int, input().split())
    b1, b2, b3, b4, b5, b6, b7, b8 = map(int, input().split())
    print(17517)
elif a == 5:
    a1, a2, a3 = map(int, input().split())
    if a==1 or b==2 or c==3:
        b1, b2, b3 = map(int, input().split())
        print(0)
    

### FIXED CODE ###

N = int(input()) 
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
A = list(range(1,N+1))
Alist=[]
import itertools
for v in itertools.permutations(A):
        Alist.append(v)
a_num = Alist.index(P)+1
b_num = Alist.index(Q)+1
print(abs(b_num - a_num))
S = input()

tag = 'keyence'

ans = 0

for i in range(1, 7):
    f_tag = tag[0:i]
    a_tag = tag[i:7]
    f1 = 1
    now = 0
    
    for j in range(len(S)-7):
        for k in range(i):
            if not S[j+k]==f_tag[k]:
                break
        else:
            f1 = f1 + 1
            now = j+i
    
    for j in range(now, len(S)-i):
        for k in range(7-i):
            if not S[j+k]==a_tag[k]:
                break
        else:
            f1 = f1+1
    if f1==3 or (f1==2 and i==0) or (f1==2 and i==7):
        ans =1
    
for i in range(len(S)-6):
    for j in range(7):
        if not S[i+j]==tag[j]:
            break
    else:
        ans = 1
    
if ans==1:
    print('YES')
else:
    print('NO')

### FIXED CODE ###

S = input()

tag = 'keyence'

ans = 0

if S[0:7]==tag:
    ans = 1
elif S[len(S)-7:len(S)]==tag:
    ans = 1
else:
    for j in range(1, 6):
        f_tag = tag[0:j]
        a_tag = tag[j+1:7]
        f = 1
        for k in range(len(f_tag)):
            if not S[k]==f_tag[k]:
                f = -1
        for k in range(len(a_tag)):
            if not S[len(S)-len(a_tag)+k]==a_tag[k]:
                f = -1
        if f>0:
            ans = 1

if ans>0:
    print('YES')
else:
    print('NO')
x,y = map(int,input().split())
crain = (4 * x - y) / 2
if y>=2x and y<=4x and y%2==0:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

x,y = map(int,input().split())
if y>=2*x and y<=4*x and y%2==0:
    print("Yes")
else:
    print("No")