Harryxun/stf_run huggingface dataset:
N,M=map(int,input().split())
A=[[] for i in range(N)]
for i in range(M):
    Pi,Si=map(str,input().split())
    Pi=int(Pi)
    A[Pi-1].append(Si)

nAC=0
nWA=0
for i in range(N):
    if len(A[i])==0:
        pass
    else:
        j=0 
        while A[i][j]=="WA":
            nWA+=1
            j+=1
            if j>len(A[i]):
                break
            else:
                pass
        if A[i][j]=="AC":
            nAC+=1
        else:
            pass
print("{:1}{:2}".format(nAC,nWA))



### FIXED CODE ###

#print("<input>") #
N,M=map(int,input().split())
A=[[] for i in range(N)]
for i in range(M):
    Pi,Si=map(str,input().split())
    Pi=int(Pi)
    A[Pi-1].append(Si)

#print("<test>") #
#print("A=",A) #

nAC=0
nWA=0
inWA=0
j=0
for i in range(N):
    #print("i=",i) #
    if len(A[i])==0:
        pass
    else: 
        while A[i][j]=="WA":
            inWA+=1
            nWA+=1
            #print("j=",j) #
            #print("inWA=",inWA) #
            #print("nWA=",nWA) #
            if j==len(A[i])-1:
                nWA-=inWA
                break
            else:
                pass
            j+=1
        if A[i][j]=="AC":
            nAC+=1
        else:
            pass
        inWA=0
        j=0
        #print("inWA=",inWA) #
        #print("nWA=",nWA) #
        

#print("<ans>") #
print("{0} {1}".format(nAC,nWA))
N,A,B = map(int, [input() for i in range(3)])

def sum(n):
    str_n = str(n)
    ans = 0
    for i in range(len(str_n)):
        ans += int(str_n[i])
    return ans

ans1 = 0
for i in range(N+1):
    if A <= sum(i) <= B:
        ans1 += i
    else:
        pass
print(ans1)


### FIXED CODE ###

def sum(n):
    str_n = str(n)
    ans = 0
    for i in range(len(str_n)):
        ans += int(str_n[i])
    return ans

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

ans1 = 0
for i in range(N+1):
    if A <= sum(i) <= B:
        ans1 += i
    else:
        continue
print(ans1)
for i in range(4):
    a[i] = int(input())
print(min(a[0],a[1]) + min(a[2], a[3]))    

### FIXED CODE ###

a = [0, 0, 0, 0]
for i in range(4):
    a[i] = int(input())
print(min(a[0],a[1]) + min(a[2], a[3]))
input = sys.stdin.readline

a, b = map(int, input().rstrip().split())
print(a + b // 2)# -*- coding: utf-8 -*-

import math
import sys
from operator import itemgetter
input = sys.stdin.readline

# a = int(input().rstrip())
# a, b = map(int, input().rstrip().split())
# D = list(map(int, input().rstrip().split()))
# H = [int(input().rstrip()) for _ in range(L)]
# DD = [[0 for j in range(100)] for i in range(200)]
# dict = {} ## dictionary

# a = sorted(a, key=lambda x: x[1]))
# if __name__ == '__main__':

a, b = map(int, input().rstrip().split())
print(a + b // 2)

### FIXED CODE ###

x, y = map(int, input().split())
print(x + y // 2)
def sakujo():
 moji1 = raw_input()
 moji2 = raw_input()
  
 a, b = len(moji1), len(moji2)
 x1 = [for i in range(b+1)]
 for i in range(a):
  e1 = seq1[i]
  x2 = x1+[]
  for j in range(b):
   if e1 == moji2[j]:
    x1[j+1] = x2[j] + 1
   elif x1[j+1] < x1[j]:
    x1[j+1] = x1[j]
 return x1[-1]

 
n=input()
for ix in range(n):
 def sakujo

### FIXED CODE ###

def longest():
    alps1 = raw_input()
    alps2 = raw_input()
    
    x, y = len(alps1), len(alps2)
    k = [0 for i in range(y+1)]
    for i in range(x):
        e1 = alps1[i]
        l = k+[]
        for j in range(y):
            if e1 == alps2[j]:
                k[j+1] = l[j] + 1
            elif k[j+1] < k[j]:
                k[j+1] = k[j]
 
    return k[-1]
    
n = input()
for i in range(n):
    print longest()
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    s = list(input().strip())
    t = list(input().strip())
    s.sort()
    t.sort(reverse=True)

    min_len = min(len(s), len(s))
    same = True
    for i in range(min_len):
        if s[i] < t[i]:
            print("Yes")
            return
        if s[i] != t[i]:
            same = False
    if same and len(s) < len(t):
        print("Yes")
    else:
        print("No")

main()


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    s = list(input().strip())
    t = list(input().strip())
    s.sort()
    t.sort(reverse=True)

    min_len = min(len(s), len(t))
    same = True
    for i in range(min_len):
        if s[i] < t[i]:
            print("Yes")
            return
        if s[i] != t[i]:
            same = False
    if same and len(s) < len(t):
        print("Yes")
    else:
        print("No")

main()
n = int(input())
a = list(map(int,input().split()))
a.append(10**10)
counter = 1
ans = 0
for i in range(n):
    if a[i] == a[i+1]:
        counter += 1
    else:
        if counter %2 == 0 and counter != 1 :
            ans += counter/2
        elif counte %2 != 0 and counter != 1:
            ans += int(counter/2)
        counter = 1
print(int(ans))

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
a.append(10**10)
counter = 1
ans = 0
for i in range(n):
    if a[i] == a[i+1]:
        counter += 1
    else:
        if counter %2 == 0 and counter != 1 :
            ans += counter/2
        elif counter %2 != 0 and counter != 1:
            ans += int(counter/2)
        counter = 1
print(int(ans))
"""
import numpy as np
N, M = map(int, input().split())
cities = {}
Y = {}
for i in range(M):
    p,y = map(int, input().split())
    cities[i] = p
    Y[i] = y

ans = {}
sorted_Y = sorted(Y.items(), key=lambda x:x[1])
P_i = np.zeros(N)
for i,y in sorted_Y:
    p = cities[i]
    P_i[p-1] += 1
    ans[i] = (p, int(P_i[p-1]))

for i in range(M):
    print('{0:06}{1:06}'.format(ans[i][0], ans[i][1]))
"""

n, m = map(int,input().split())
pys = []
for i in range(m):
    x = map(int, input().split())
    x = [x[0],x[1],i]
    pys.append(x)

pys.sort()
pp = -1
lid = 0
ans = []
for i in range(m):
    if pp == pys[i][0]:
        lid += 1
    else:
        lid = 1
        pp = pys[i][0]
    ans.append(pp*10**6+lid)

for v in ans:
    print(':012d'.format(v))


### FIXED CODE ###

import numpy as np
N, M = map(int, input().split())
cities = {}
P = {}
Y = {}
for i in range(M):
    p,y = map(int, input().split())
    cities[i] = p
    Y[i] = y

ans = {}
sorted_Y = sorted(Y.items(), key=lambda x:x[1])
P_i = np.zeros(N)
for i,y in sorted_Y:
    p = cities[i]
    P_i[p-1] += 1
    ans[i] = (p, int(P_i[p-1]))

for i in range(M):
    print('{0:06}{1:06}'.format(ans[i][0], ans[i][1]))
n, k = map(int, input().split())
print(k * ((nk - 1) ** (n - 1)))

### FIXED CODE ###

n, k = map(int, input().split())
print(k * ((k - 1)**(n - 1)))
prinm(48-int(input()))

### FIXED CODE ###

print(48-int(input()))
N, A, B = map(int, input().split())
S = input()
passed = []

for i in range(N):
  if S[i] == 'c':
    print('No')
  elif S[i] == 'a':
    if len(passed) <= A+B:
      print('Yes')
      passed.append('a')
    else: print('No')
  else:
    if len(passed) <= A+B and passed.count('b') <= B:
      print('Yes')
      passed.append('b')
    else: print('No')

### FIXED CODE ###

s = input()
chs = list(s)
str = 'CODEFESTIVAL2016'
count = 0
for i, ch in enumerate(chs):
  if ch != str[i]:
    count += 1
print(count)
import sys
input = sys.stdin.readline

N, M = map(int, input().split())
G = [set() for _ in range(N+1)]
for _ in range(M):
    A, B = map(int, input().split())
    G[A].add(B)
    G[B].add(A)
if M % 2 == 1:
    print(-1)
    exit()
G2 = [set() for _ in range(N+1)]
parent = [0] * (N+1)
depth = [-1] * (N+1)
depth[1] = 0
stack = [1]
while stack:
    v = stack.pop()
    if len(G[v]) == 0:
        continue
    if parent[v] != 0:
        depth[v] = depth[parent[v]] + 1
    for c in G[v]:
        G2[v].add(c)
        parent[c] = v
        G[c].remove(v)
        stack.append(c)
nodes = sorted(list(range(1, N+1)), key=lambda v: -depth[v])
ans = []
for v in nodes:
    for c in G2[v]:
        ans.append((v, c))
    if len(G2[v]) % 2 == 1:
        if v == 1:
            print(-1)
            exit()
        p = parent[v]
        ans.append((v, p))
        G2[p].remove(v)
for u, v in ans:
    print(u, v)


### FIXED CODE ###

import sys
input = sys.stdin.readline

N, M = map(int, input().split())
G = [set() for _ in range(N+1)]
for _ in range(M):
    A, B = map(int, input().split())
    G[A].add(B)
    G[B].add(A)
if M % 2 == 1:
    print(-1)
    exit()
G2 = [set() for _ in range(N+1)]
parent = [0] * (N+1)
depth = [-1] * (N+1)
depth[1] = 0
stack = [1]
while stack:
    v = stack.pop()
    if len(G[v]) > 0 and v != 1:
        depth[v] = depth[parent[v]] + 1
    for c in G[v]:
        G2[v].add(c)
        parent[c] = v
        if v in G[c]:
            G[c].remove(v)
        stack.append(c)
    G[v] = set()
nodes = sorted(list(range(1, N+1)), key=lambda v: -depth[v])
ans = []
for v in nodes:
    for c in G2[v]:
        ans.append((v, c))
    if len(G2[v]) % 2 == 1:
        p = parent[v]
        ans.append((v, p))
        G2[p].remove(v)
for u, v in ans:
    print(u, v)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
import functools
import math

input = sys.stdin.readline
n, x = map(int, input().split())
a = input().split()
b = list(map(int, a))
b.append(x)
b.sort()
c = []
if len(b) == 2:
    print(b[1] - b[0])
    exit(0)
for i in range(1, n - 1):
    c.append(b[i] - b[i - 1])

gcd = functools.reduce(math.gcd, c)
print(gcd)


### FIXED CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys

input = sys.stdin.readline
n, x = map(int, input().split())
a = input().split()
b = list(map(int, a))
b.append(x)
b.sort()
if len(b) == 2:
    print(b[1] - b[0])
    exit(0)
c = [abs(a - x) for a in b]


def gcd(a, b):
    while b > 0:
        a, b = b, a % b
    return a


ans = c[0]
for i in range(len(c)):
    ans = gcd(c[i], ans)
print(ans)
import sys
a=[]
for i in sys.stdin:
    a.append(map(int,i.split()))
for i in a:
    print(str(len(str(i[0]+a[1]))))

### FIXED CODE ###

import sys
a=[]
for i in sys.stdin:
    a.append(map(int,i.split()))
for i in a:
    print(str(len(str(i[0]+i[1]))))
s = input()
for i in range(len(s)):
    s = s[:-1]
    if len(s)%2 == 0:
        if s[:len(s)/2] == s[len(s)/2:]:
            print(len(s))
            break

### FIXED CODE ###

s = input()
for i in range(len(s)):
    s = s[:-1]
    if len(s)%2 == 0:
        if s[:int(len(s)/2)] == s[int(len(s)/2):]:
            print(len(s))
            break
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    X, t = li_input()

    print(max(X - t), 0)


main()


### FIXED CODE ###

import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(10000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


# --------------------------------------------

dp = None


def main():
    X, t = li_input()

    print(max(X - t, 0))


main()
K = int(input())
X = int(input())
s = X-K+1
e = X+K-1
for i in range(s,e):
    print(str(i)+' ')

### FIXED CODE ###

S = input().split()
K = int(S[0])
X = int(S[1])
s = X-K+1
e = X+K-1
for i in range(s, e):
    print(str(i)+' ')
print(e)
s = input()
x, y = map(int, input().split())
sx, sy = 0, 0
dic = {"U":(1,0), "R":(0, 1), "D":(-1,0), "L":(0, -1)}
rec = []


def dfs(x1, y1, pos, k):
    if k == len(s):
        rec.append((x1, y1))
        return
    else:
        if s[k] == "F":
            nx, ny = x1 + dic[pos][0], y1 + dic[pos][1]
            dfs(nx, ny, pos, k + 1)
        else:
            if pos == "U" or pos == "D":
                dfs(x1, y1, "R", k + 1)
                dfs(x1, y1, "L", k + 1)
            else:
                dfs(x1, y1, "U", k + 1)
                dfs(x1, y1, "D", k + 1)


dfs(0, 0, "R", 0)
if (y, x) in rec:
    print("Yes")
else:
    print("No")



### FIXED CODE ###

S = input()
x, y = map(int, input().split())

T = S.split("T")
u, v = [len(T[0])], [0]
dp = [u, v]
for i in range(1, len(T)):
    s = set()
    k = len(T[i])
    if i % 2 != 0:
        Q = dp[1]
        for j in Q:
            s.add(j - k)
            s.add(j + k)
        dp = [dp[0], list(s)]
    else:
        Q = dp[0]
        for j in Q:
            s.add(j - k)
            s.add(j + k)
        dp = [list(s), dp[1]]
if x in dp[0] and y in dp[1]:
    print("Yes")
else:
    print("No")
A,B,K=map(int,input().split())
i=0
j=1
a=[]
if A%j==0 and B%j==0:
    a.append(j)
    j+=1
print(a[-4])

### FIXED CODE ###

A,B,K=map(int,input().split())
i=0
j=1
a=[]
while j<=max(A,B):
    if A%j==0 and B%j==0:
        a.append(j)
    j+=1
print(a[-K])
a,b,c=map(int,input().split())
ans=0
for s in range(a):
    d,e=map(int,input().split())
    if b<=d and c<=e:
        ans+=1
print(ans)

### FIXED CODE ###

print(input().count("2"))
from collections import deque

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

graph = [[] for _ in range(m)]
for _ in range(m):
  a, b = map(int, input().split())
  graph[a - 1].append(b - 1)
  graph[b - 1].append(a - 1)

ans = [-1] * (n - 1)

q = deque()
q.append(0)
used = {0}
while q:
    node = q.popleft()
    for next_node in graph[node]:
        if next_node in used:
          continue
        q.append(next_node)
        used.add(next_node)
        ans[next_node - 1] = node + 1

print('Yes')
print(*ans, sep='\n')

### FIXED CODE ###

from collections import deque

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

graph = [[] for _ in range(n)]
for _ in range(m):
  a, b = map(int, input().split())
  graph[a - 1].append(b - 1)
  graph[b - 1].append(a - 1)

ans = [-1] * (n - 1)

q = deque()
q.append(0)
used = {0}
while q:
  node = q.popleft()
  for next_node in graph[node]:
    if next_node in used:
      continue
    q.append(next_node)
    used.add(next_node)
    ans[next_node - 1] = node + 1

print('Yes')
print(*ans, sep='\n')
N = int(input())
h = list(map(int, input().split()))

DP = [0, abs(h[0]-h[1])]

for i in range(N-2):
  DP += min((DP[-2] + abs(h[i]-h[i+2])),(DP[-1] + abs(h[i+2]-h[i+1])))
  
print(DP[-1])

### FIXED CODE ###

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

DP = [0, abs(h[0]-h[1])]
for i in range(N-2):
  DP += [min(DP[-2] + abs(h[i]-h[i+2]),DP[-1] + abs(h[i+1] - h[i+2]))]
  
print(DP[-1])
N,M,K=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
minute=0
ans=0
if A[0]>K and B[0]>K: print(0)
while True:
    if not A and not B:
        break
    elif not A:
        x=B[0]
        minute += x
        del B[0]
        if minute > K:
            break
        ans += 1
    elif not B:
        x=A[0]
        minute += x
        del A[0]
        if minute > K:
            break
        ans += 1
    elif A[0]!=B[0]:
        x=min(A[0],B[0])
        if A[0]<B[0]:
            del A[0]
        else:
            del B[0]
        minute+=x
        if minute>K:
            break
        ans += 1
    else:
        x=A[0]
        while True:
            i=1
            if A[i]<B[i]:
                del A[0]
                break
            elif B[i]<A[i]:
                del B[0]
                break
            else:
                i+=1
        minute += x
        if minute > K:
            break
        ans += 1

print(ans)

### FIXED CODE ###

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

a,b = [0],[0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans,j = 0,M
for i in range(N+1):
    if a[i]>K:
        break
    while b[j]>K-a[i]:
        j -= 1
    ans = max(ans,i+j)
print(ans)
import math
n,m=map(int,input().split())
s=input()
t=input()
cnt=1
i=0
flag=0

l=int(n*m/math.gcd(n,m))

r=l/m

while cnt<n:
  if s[int(i*l/m)]==t[int(i*l/n)]:
    flag=1
    cnt+=r
    i+=1
  else:
    flag=0
    break

if flag==1:
  print(l)
else:
  print(-1)


### FIXED CODE ###

def gcd(a, b):
  while b:
	  a, b = b, a % b
  return a

n,m=map(int,input().split())
s=input()
t=input()
cnt=1
i=0
flag=0

l=int(n*m/gcd(n,m))

r=l/m

while cnt<n:
  if s[int(i*l/m)]==t[int(i*l/n)]:
    flag=1
    cnt+=r
    i+=1
  else:
    flag=0
    break

if flag==1:
  print(l)
else:
  print(-1)
x = int(import())
print x ** 3

### FIXED CODE ###

x = int(input())
print (x ** 3)
n=int(input())
a=list(map(int,input().split()))
u=a[0]<=a[1]
d=a[0]>=a[1]
res=0
for i in range(2,n):
    u=u and a[i-1]<=a[i]
    d=d and a[i-1]>=a[i]
    #print(i,u,d)
    if not any([u,d]):
        res+=1
        u=True
        d=True
print(res+1)
    

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
if n==1:
    print(1)
else:
    u=a[0]<=a[1]
    d=a[0]>=a[1]
    res=0
    for i in range(2,n):
        u=u and a[i-1]<=a[i]
        d=d and a[i-1]>=a[i]
        #print(i,u,d)
        if not any([u,d]):
            res+=1
            u=True
            d=True
    print(res+1)
N = input()
B = list(map(int, input().split()))
A = []
for i in range(N):
  if i == 0:
    A.append(B[0])
  elif i == N-1:
    A.append(B[N-2])
  else:
    A.append(min(B[i], B[i-1]))
print(sum(A))

### FIXED CODE ###

N = int(input())
B = list(map(int, input().split()))
A = []
for i in range(N):
  if i == 0:
    A.append(B[0])
  elif i == N-1:
    A.append(B[N-2])
  else:
    A.append(min(B[i], B[i-1]))
print(sum(A))
int(input())
s = list(input())
 
a = n//2
if n % 2 == 1:
    print("No")
elif s[0:a] == s[a:n]:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = int(input())
s = input()
if n%2 == 1:
    print("No")
elif s[0:n//2]==s[n//2:n]:
    print("Yes")
else:
    print("No")
import numpy as np
N, K = map(int, input().split())
h = [int(x) for x in input().split()]
dp = [np.Infinity] * N
dp[0] = 0
for i in range(1, N):
    for j in range(1, K+1):
        if i - j >= 0:
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i-j]))
print(dp[-1])

### FIXED CODE ###

N, K = map(int, input().split())
h = [int(x) for x in input().split()]
dp = [10**10] * N
dp[0] = 0
for i in range(1, N):
    for j in range(1, K+1):
        if i - j >= 0:
            dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i-j]))
print(dp[-1])
numbers = {'1': 2, '2': 5, '3': 5, '4': 4, '5': 5, '6': 6, '7': 3, '8': 7, '9': 6}

N, M = map(int, input().split())
A = list(input().split())
cands = [(a, numbers[a]) for a in A]

dp = {i: None for i in range(1, N+1)}
for c in cands:
    dp[c[1]] = int(c[0])
for i in range(2, N+1):
    for c in cands:
        j = i - c[1]
        if j >= 1 and dp[j] is not None:
            if dp[i] is None:
                dp[i] = int(''.join(str(dp[j]) + c[0]))
            else:
                if len(str(dp[i])) <  len(str(dp[j]) + c[0]):
                    dp[i] = int(str(dp[j]) + c[0])
                elif len(str(dp[i])) ==  len(str(dp[j]) + c[0]):
                    dp[i] = max(dp[i], int(''.join(sorted(str(dp[j]) + c[0], reverse=True))))
print(''.join(sorted(dp[N], reverse=True)))

### FIXED CODE ###

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

numbers = [None, 2, 5, 5, 4, 5, 6, 3, 7, 6]
dp = {i: -1 for i in range(N+1)}
dp[0] = 0
for i in range(N+1):
    for a in A:
        j = i + numbers[a]
        if j <= N:
            dp[j] = max(dp[j], dp[i]*10 + a)
print(dp[N])
X = int(input())
check =[]
check2=[]
for i in range(1,33):
    for s in range(2,11):
        check.append(pow(i,s))


for i in check:
    if i<X:
        check2.append(i)

print(max(check2))


### FIXED CODE ###

X = int(input())
check =[]
check2=[]
for i in range(1,33):
    for s in range(2,11):
        check.append(pow(i,s))

#print(check)
for i in check:
    if i<=X:
        check2.append(i)
print(max(check2))
#coding: utf-8

N_list = list(input())

if N_list[0] == N_list[1] == N_list[2]:
	print("Yes")
elif N_list[1] == N_list[2] == N_list[3]:
	print("Yes")
elif N_list[2] == N_list[3] == N_list[4]:
	print("Yes")
else:
	print("No")

### FIXED CODE ###

#coding: utf-8

N_list = list(input())

if N_list[0] == N_list[1] == N_list[2]:
	print("Yes")
elif N_list[1] == N_list[2] == N_list[3]:
	print("Yes")
else:
	print("No")
import sys

N, K = [int(x) for x in input().split()]
x = [int(x) for x in input().split()]

r = 0
for idx, xi in enumerate(x):
    r = idx


list = []

S = r - K
if x[r] == 0:
    S += 1
S = max(S, 0)

for s in range(S, r+1):
    e = s + K - 1
    if len(x) <= e:
        break
    list.append(abs(x[e] - x[s]) + abs(x[s]))
    list.append(abs(x[e] - x[s]) + abs(x[e]))

print(min(list))

sys.exit(0)


### FIXED CODE ###

N, i = [int(x) for x in input().split()]

print(N - i + 1)
K = int(input())

if K % 2 == 0 or K % 5 == 0:
    i = -1
else:
    if K % 7 == 0:
        K = K%7
    L = 9*K
    a = 10 % L
    if a == 1:
        i = 1
    else:
        for i in range(2, L+1):
            a = (a*10) % L
            if a == 1:
                break
print(i)

### FIXED CODE ###

K = int(input())

if K % 2 == 0 or K % 5 == 0:
    i = -1
else:
    if K % 7 == 0:
        K = K//7
    L = 9*K
    a = 10 % L
    if a == 1:
        i = 1
    else:
        for i in range(2, L+1):
            a = (a*10) % L
            if a == 1:
                break
print(i)
def main():
    n = int(input())
    nums = list(map(int, input().split()))
    nums.sort()
    used = [False] * n

    num_bin_digits = [1 << len(f"{x:b}") for x in nums]
    cnt = 0

    for cur in reversed(range(n)):
        if used[cur]:
            continue

        num = nums[cur]
        power_of_2 = num_bin_digits[cur]
        pair = power_of_2 - num
        idx = -1
        if pair in nums[:cur]:
            idx = nums.index(pair)

        if idx != -1 and not used[idx]:
            used[idx] = True
            cnt += 1

    print(cnt)
    return

main()

### FIXED CODE ###

import math
from collections import defaultdict

def main():
    _ = int(input())
    nums = list(map(int, input().split()))
    n = len(nums)
    nums.sort()

    nums_cnt = defaultdict(int)
    for num in nums:
        nums_cnt[num] += 1

    cnt = 0
    #print(num_bin_digits)

    for cur in reversed(range(n)):
        num = nums[cur]
        if nums_cnt[num] <= 0:
            continue

        power_of_2 = 1 << math.ceil(math.log2(num))

        pair = power_of_2 - num


        if pair != 0 and nums_cnt[pair] > 0:
            nums_cnt[pair] -= 1
            nums_cnt[num] -= 1
            cnt += 1
        elif pair == 0 and nums_cnt[num] >= 2:
            nums_cnt[num] -= 2
            cnt += 1


        '''
        idx = bisect.bisect_left(nums, pair)
        if idx >= cur or nums[idx] != pair:
            #print('continue',pair, idx)
            continue

        while used[idx]:
            idx += 1

        if nums[idx] == pair:
            used[idx] = True
            cnt += 1

        #print(idx, num, power_of_2, pair)
        #print(cnt, nums, used)
        '''

        #print(nums_cnt)

    print(cnt)

    return

main()