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

import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N = II()
    c = str(input())

    numW = c.count("W")
    x = 1
    ans = 0
    y = 0

    for i in range(N):
        if y != 0:
            break
        if c[i] == "W":
            for j in range(x, N):
                ii = -j
                if c[ii] == "R" and j < N-i:
                    ans += 1
                    x = j+1
                    #print(i)
                    break
                if x>= N-1:
                    y += 1
                    break



    print(ans)

if __name__ == "__main__":
	main()

### FIXED CODE ###

import sys

def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
def RN(N): return [input().strip() for i in range(N)]


def main():
    N = II()
    c = str(input())

    x = 1
    ans = 0
    y = 0

    for i in range(N):
        if y != 0:
            break
        if c[i] == "W":
            for j in range(x, N):
                ii = -j
                if c[ii] == "R" and j < N-i:
                    ans += 1
                    x = j+1
                    break
                if j>= N-i:
                    y += 1
                    break



    print(ans)

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

# distutils: language=c++
# cython: language_level=3, boundscheck=False, wraparound=False
# cython: cdivision=True

def INT(): return int(input())
def MAPINT(): return map(int, input().split())
def LMAPINT(): return list(map(int, input().split()))
def STR(): return input()
def MAPSTR(): return map(str, input().split())
def LMAPSTR(): return list(map(str, input().split()))

def main():
  n = INT()
  a = LMAPINT()

  ans = [0] * (max(a) + 1)
  for x in a:
    if ans[x] != 0:
      ans[x] += 1
    else:
      for j in range(x, max(a)+1, x):
        ans[j] += 1
  
  print(len(list(filter(lambda x: ans[x] == 1, a))))


if __name__ == '__main__':
  main()

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
 
xs = [0] * (max(a) + 1)
 
for v in a:
    if xs[v] == 0:
        for j in range(v, len(xs), v):
            xs[j] += 1
    else:
        xs[v] += 1
print(len(list(filter(lambda v: xs[v] == 1, a))))
### BUGGY CODE ###

n, m, l = map(int, input().split())
d = [[float('inf')] * n for _ in range(n)]
for _ in range(m):
    a, b, c = map(int, input().split())
    d[a-1][b-1] = c
    d[b-1][a-1] = c
for i in range(n):
    for j in range(n):
        for k in range(n):
            d[j][k] = min(d[j][k], d[j][i] + d[i][k])
d2 = [[float('inf')] * n for _ in range(n)]
for i in range(n):
    for j in range(n):
        if d[i][j] <= l:
            d2[i][j] = 1
for i in range(n):
    for j in range(n):
        for k in range(n):
            d2[j][k] = min(d2[j][k], d2[j][i] + d2[i][k])
q = int(input())
for _ in range(q):
    s, t = map(int, input().split())
    print(d2[s-1][t-1]-1 if d2[s-1][t-1] != float('inf') else -1)
    


### FIXED CODE ###

#dame datta...
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix
def main():
    N, M, L = map(int, input().split())
    l = [[0] * N for _ in range(N)]
    for _ in range(M):
        a, b, c = map(int, input().split())
        if c > L:
            continue
        l[a-1][b-1] = c
        l[b-1][a-1] = c
    G = csr_matrix(l)
    d = floyd_warshall(G)
    l = [[0] * N for _ in range(N)]
    for i in range(N):
        for j in range(N):
            if d[i][j] <= L:
                l[i][j] = 1
    G = csr_matrix(l)
    d = floyd_warshall(G)
    Q = int(input())
    for _ in range(Q):
        s, t = map(int, input().split())
        s -= 1
        t -= 1
        x = d[s][t]
        if x != float('inf'):
            print(int(x)-1)
        else:
            print(-1)
main()
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
q = int(input())
B = [list(map(int, input().split())) for _ in range(q)]

# print(n,a,q,B)

# from collections import Counter

# _a = Counter()

for (b, c) in B:
    a = [c if x == b else x for x in a]
    print(sum(a))


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
q = int(input())
B = [list(map(int, input().split())) for _ in range(q)]

from collections import Counter
ans = sum(a.copy())
a = Counter(a)

for (b, c) in B:
    ans += a[b] * (c-b)
    print(ans)
    a[c] += a[b]
    a[b] = 0
### BUGGY CODE ###

n,p=map(int,input().split())
 
if n==1:
    print(p)
else:
    x=round((p**(1/n)+1))+1
    for i in range(x,0,-1):        
                if p%(i**n)==0:
                    print(i)
                    break
 

### FIXED CODE ###

N, P = map(int, input().split())
ans = 1
 
if N >= 45:
  print(ans)
elif N == 1:
  print(P)
  
 
  
else:
  i = 1
  while(i**N <= P):
    if P % (i**N) == 0:
      ans = i
    i += 1
  print(ans)
### BUGGY CODE ###

# coding: utf-8
# Your code here!
N, M = map(int, input().split())
List = list(map(int, input().split()))
BC = [list(map(int, input().split())) for i in range(M)]

SumList = [sum(List)]

i=0
while i<M:
    CheckList = List
    j=0
    while j<BC[i][0]:
        CheckList[CheckList.index(min(CheckList))] = BC[i][1]
        j+=1
    SumList.append(sum(CheckList))
    i+=1

print(max(SumList))

### FIXED CODE ###

import numpy as np
 
N,M = map(int,input().split())
 
A = np.array([int(x) for x in input().split()],dtype=np.int64)
A.sort()
 
BC = np.array([[int(x) for x in input().split()] for _ in range(M)])
B = BC[:,0]
C = BC[:,1]
 
idx = C.argsort()
B = B[idx][::-1]
C = C[idx][::-1]
 
p = 0
for b,c in zip(B,C):
  A[p:p+b] = np.maximum(A[p:p+b],c)
  p += b
 
answer = A.sum()
print(answer)
### BUGGY CODE ###

class Combination:
    '''MOD上の
    計算量：階乗・逆元テーブルの作成O(N)
    nCkを求めるO(1)'''

    def __init__(self, n, MOD):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % MOD)
        self.inv_fact = [pow(self.fact[i], MOD - 2, MOD) for i in range(n + 1)]
        self.MOD = MOD

    def factorial(self, k):
        """k!を求める O(1)"""
        return self.fact[k]

    def inverse_factorial(self, k):
        """k!の逆元を求める O(1)"""
        return self.inv_fact[k]

    def permutation(self, k, r):
        """kPrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[r]) % self.MOD

    def combination(self, k, r):
        """kCrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD


h, w, n = map(int, input().split())
info = [(1, 1)] + [tuple(map(int, input().split())) for i in range(n)] + [(h, w)]
n += 2
MOD = 10**9 + 7
comb = Combination(w+h+1, MOD)

dp = {}
dp[0] = (0, 1)
def solve(ind):
    if ind in dp:
        return dp[ind]
    i, j = info[ind]
    dp0 = 0
    dp1 = 0
    for ind2 in range(n):
        if ind2 == ind:
            continue
        pi, pj = info[ind2]
        if pi <= i and pj <= j:
            dp0 += comb.combination((i+j)-(pi+pj), i-pi) * solve(ind2)[1]
            dp1 += comb.combination((i+j)-(pi+pj), i-pi) * solve(ind2)[0]
            dp0 %= MOD
            dp1 %= MOD
    dp[ind] = (dp0, dp1)
    return dp[ind]

for i in range(n):
    solve(i)
all_ptn = comb.combination((w-1+h-1), h-1)
print((dp[n-1][0] - dp[n-1][1]) % MOD)


### FIXED CODE ###

class Combination:
    def __init__(self, n, MOD):
        self.fact = [1] * (n + 1)
        for i in range(1, n + 1):
            self.fact[i] = self.fact[i-1] * i % MOD
        self.inv_fact = [pow(self.fact[i], MOD - 2, MOD) for i in range(n + 1)]
        self.MOD = MOD

    def factorial(self, k):
        """k!を求める O(1)"""
        return self.fact[k]

    def inverse_factorial(self, k):
        """k!の逆元を求める O(1)"""
        return self.inv_fact[k]

    def permutation(self, k, r):
        """kPrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[r]) % self.MOD

    def combination(self, k, r):
        """kCrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.MOD


h, w, n = map(int, input().split())
info = [(1, 1)] + [tuple(map(int, input().split())) for i in range(n)] + [(h, w)]
info = sorted(info)
n += 2
MOD = 10**9 + 7
comb = Combination(w+h+1, MOD)

dp = {}
dp[0] = (0, 1)
def solve(ind):
    if ind in dp:
        return dp[ind]
    i, j = info[ind]
    dp0 = 0
    dp1 = 0
    for ind2 in range(n):
        if ind2 == ind:
            continue
        pi, pj = info[ind2]
        if pi <= i and pj <= j:
            tmp = comb.combination((i+j)-(pi+pj), i-pi)
            dp0 += tmp * solve(ind2)[1] % MOD
            dp1 += tmp * solve(ind2)[0] % MOD
    dp[ind] = (dp0, dp1)
    return dp[ind]

for i in range(n):
    solve(i)
print((dp[n-1][0] - dp[n-1][1]) % MOD)
### BUGGY CODE ###

import numpy as np
n, x = map(int, input().split())
DP = np.zeros((n,n), dtype=np.int32)
a = np.array(list(map(int, input().split())), dtype=np.int32)
DP[0] = a
for i in range(n-1):
    for j in range(n):
        DP[i+1][j] = min(DP[i][j], DP[i][j-1])
ans = float("inf")
for i in range(n):
    ans = min(ans, sum(DP[i])+i*x)
print(int(ans))

### FIXED CODE ###

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

# 空間計算量を減らしてみる
DP = a[:]
ans = sum(DP)
for i in range(n-1):
    DP = [min(DP[j],DP[j-1]) for j in range(n)]
    ans = min(ans, sum(DP) + (i+1)*x)
print(ans)
### BUGGY CODE ###

a,b,n=map(int,input().split())
ans=[]
for i in range(n+1):
    ans.append(a*i//b-a*(i//b))
print(max(ans))

### FIXED CODE ###

a,b,n=map(int,input().split())
if b-1>n:
    ans=n
else:
    ans=b-1
print(a*ans//b-a*(ans//b))
### BUGGY CODE ###

ans = 1
n = input()
n = int(n)
nums = input().split()
for i in range(n):
    mul = int(nums[i])
    ans = ans * mul

if ans > 10**18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

ans = 1
n = input()
n = int(n)
nums = input().split()
for i in range(n):
    mul = int(nums[i])
    if mul == 0:
        print(0)
        exit()


for i in range(n):
    mul = int(nums[i])
    ans = ans * mul
    if ans > 10**18:
        print(-1)
        exit()

if ans > 10**18:
    print(-1)
else:
    print(ans)

exit()
### BUGGY CODE ###

n, k = map(int,input().split())
a = list(map(int,input().split()))
def trans(v):
  l = [0]*(k+1)
  for i in range(k+1):
    l[i] = (v&1)
    v >>= 1
  return l

a.sort()
lef = [1]*n
rig = [1]*n
mask = (1 << (k+1)) - 1
for i in range(n-1):
  lef[i+1] = lef[i] | (lef[i] << a[i]) & mask
  rig[-i-2] = rig[-i-1] | (rig[-i-1] << a[-i-1]) & mask
ok = -1
ng = n
while ng - ok > 1:
  mid = (ng + ok) // 2
  lc = trans(lef[mid])
  rc = trans(rig[mid])
  # print(a[mid], lc, rc)
  rcs = [0]*(k+2)
  for i in range(k+1):
    rcs[i+1] = rcs[i] + rc[i]
  for i in range(k+1):
    if lc[i] and rcs[k-i] - rcs[max(k - a[mid] - i, 0)] > 0:
      ng = mid
      break
  else:
    ok = mid
print(ok + 1)

### FIXED CODE ###

n, k = map(int,input().split())
a = [k+1 if x > k else x for x in map(int,input().split())]
a.sort()
lef = [1]*n
rig = [1]*n
mask = (1 << (k+1)) - 1
for i in range(n-1):
  lef[i+1] = lef[i] | (lef[i] << a[i]) & mask
  rig[-i-2] = rig[-i-1] | (rig[-i-1] << a[-i-1]) & mask
ok = -1
ng = n
while ng - ok > 1:
  mid = (ng + ok) // 2
  if a[mid] >= k:
      ng = mid
      continue
  lc = lef[mid]
  rc = rig[mid]
  cov = ((1 << k) - 1) ^ ((1 << (k - a[mid])) - 1)
  for i in range(k):
    if lc & 1 and rc & cov:
      ng = mid
      break
    lc >>= 1
    cov >>= 1
  else:
    ok = mid
print(ok + 1)
### BUGGY CODE ###

N = int(input())
S = ['']* N
ans = 0
for i in range(N):
    S[i]= sorted(input())
    ans += S.count(S[i]) - 1

print(ans)


### FIXED CODE ###

from collections import defaultdict
Sdic = defaultdict(int)

N = int(input())
S = ['']* N
ans = 0
for i in range(N):
    Sdic[str(sorted(input()))] += 1

for i in Sdic.keys():
    ans += (Sdic[i] * (Sdic[i] - 1)) // 2

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

H,W,M = map(int,input().split())
P = [0]*(H+1)
Q = [0]*(W+1)
A = []
for k in range(M):
    a,b = map(int,input().split())
    P[a] += 1
    Q[b] += 1
    A.append((a,b))
Pmax = max(P)
Qmax = max(Q)
Pindex = []
Qindex = []
for i in range(H+1):
    if P[i] == Pmax:
        Pindex.append(i)
for i in range(W+1):
    if Q[i] == Qmax:
        Qindex.append(i)
ans = Pmax+Qmax-1
key = 0
for x in Pindex:
  for y in Qindex:
    if (x,y) not in A:
      ans += 1
      key = 1
      break
  if key == 1:
    break
print(ans)


### FIXED CODE ###

H,W,M = map(int,input().split())
P = [0]*(H+1)
Q = [0]*(W+1)
A = set()
for k in range(M):
    a,b = map(int,input().split())
    P[a] += 1
    Q[b] += 1
    A.add((a,b))
Pmax = max(P)
Qmax = max(Q)
Pindex = []
Qindex = []
for i in range(H+1):
    if P[i] == Pmax:
        Pindex.append(i)
for i in range(W+1):
    if Q[i] == Qmax:
        Qindex.append(i)
ans = Pmax+Qmax-1
key = 0
for x in Pindex:
  for y in Qindex:
    if (x,y) not in A:
      ans += 1
      key = 1
      break
  if key == 1:
    break
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under


N, M, K = map(int, input().split())
mod = 10**9 + 7

x = N*N*(M*M*(M+1)//2 - M*(M+1)*(2*M+1)//6)
y = M*M*(N*N*(N+1)//2 - N*(N+1)*(2*N+1)//6)
ans = cmb(N*M-2, K-2) * (x + y) % mod
print(ans)

### FIXED CODE ###

from math import factorial


def comb(n, k, mod):
  if n < 0 or k < 0 or n < k:
      return 0
  if n == 0 or k == 0:
      return 1
  
  a=factorial(n) % mod
  b=factorial(k) % mod
  c=factorial(n-k) % mod
  return (a*power_func(b, mod-2, mod)*power_func(c, mod-2, mod)) % mod


def power_func(a,b,mod):
  if b == 0:
      return 1
  if b % 2 == 0:
    d = power_func(a, b//2, mod)
    return d*d % mod
  if b % 2 == 1:
    return (a*power_func(a, b-1, mod)) % mod


N, M, K = map(int, input().split())
mod = 10**9 + 7


x = N*N*(M*M*(M+1)//2 - M*(M+1)*(2*M+1)//6)
y = M*M*(N*N*(N+1)//2 - N*(N+1)*(2*N+1)//6)
ans = comb(N*M-2, K-2, mod) * (x + y) % mod
print(ans)
### BUGGY CODE ###

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


def dsMakeSet(ds, x):
    ds[x] = x


def dsFind(ds, x):
    while ds[x] != x:
        x = ds[x]

    return x


def dsUnion(ds, x, y):
    xRoot = dsFind(ds, x)
    yRoot = dsFind(ds, y)
    
    if xRoot != yRoot:
        ds[yRoot] = xRoot
        return True

    return False


def main():
    N, M = map(int, input().split())
    ds = {}

    for i in range(N):
        dsMakeSet(ds, i+1)

    n = 0
    for i in range(M):
        X,Y,Z = map(int, input().split())
        if dsUnion(ds, X, Y):
            n += 1
        
    print(N - n)
        

if __name__ == '__main__':
    main()


### FIXED CODE ###

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


def dsMakeSet(ds, x):
    ds[x] = x


def dsFind(ds, x):
    if ds[x] == x:
        return x

    x0 = x
    while ds[x] != x:
        x = ds[x]

    ds[x0] = x
    return x


def dsUnion(ds, x, y):
    xRoot = dsFind(ds, x)
    yRoot = dsFind(ds, y)
    
    if xRoot != yRoot:
        ds[yRoot] = xRoot
        return True

    return False


def main():
    N, M = map(int, input().split())
    ds = {}

    for i in range(N):
        dsMakeSet(ds, i+1)

    n = 0
    for i in range(M):
        X,Y,Z = map(int, input().split())
        if dsUnion(ds, X, Y):
            n += 1
        
    print(N - n)
        

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

N = int(input())
A = list(map(int, input().split()))
ans = 1
for a in A:
  ans *= a
if ans > 10**18:
  print(-1)
else:
  print(ans)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
ans = 1
for a in A:
  ans *= a
  if ans > 10**18:
    print(-1)
    exit()
if ans > 10**18:
  print(-1)
else:
  print(ans)
### BUGGY CODE ###

n=int(input())
List=[2 for x in range(n+1)]
List[0]=0
List[1]=1
ans=1
 
for x in range(2,n+1):
  for y in range(2*x,n+1,x):
    List[y]+=1
  ans+=x*List[x]
print(ans)


### FIXED CODE ###

n=int(input())
List=[2 for x in range(n+1)]
List[0]=0
List[1]=1
ans=1

for x in range(2,n+1):
  for y in range(2*x,n+1,x):
    List[y]+=1
  ans+=x*List[x]
print(ans)
### BUGGY CODE ###

import itertools
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
r = [x - 1 for x in r]
d = [[float("inf")] * N for i in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c


def warshall_floyd(d):
    # d[i][j]: iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

warshall_floyd(d)
# print(d)
ans = float('inf')
for x in itertools.permutations(r):
    cost = 0
    # print(x)
    for i in range(len(x) - 1):
        # print(i)
        cost += d[x[i]][x[i+1]]
    ans = min(ans, cost)
print(ans)

### FIXED CODE ###

import itertools
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
r = [x - 1 for x in r]
d = [[float("inf")] * N for i in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    d[a][b] = c
    d[b][a] = c


def warshall_floyd(d):
    # d[i][j]: iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

warshall_floyd(d)
# print(d)
ans = float('inf')
for x in itertools.permutations(r):
    cost = 0
    # print(x)
    for i in range(len(x) - 1):
        # print(i)
        cost += d[x[i]][x[i+1]]
    ans = min(ans, cost)
print(ans)
### BUGGY CODE ###


N,M,K = map(int, input().split())
A_list = list(map(int, input().split()))
B_list = list(map(int, input().split()))

# cumsum
A_cum = [0] * (N+1)
B_cum = [0] * (M+1)
ap = 0
for i, a in enumerate(A_list):
    A_cum[i+1] = ap + a
    ap += a
bp = 0
for i, b in enumerate(B_list):
    B_cum[i+1] = bp + b
    bp += b

for bi,b in enumerate(B_cum):
    if b > K:
        break

max_cnt = bi-1 
bp = bi

for i in range(N+1):
    a = A_cum[i]
    if a > K:
        break
    for bi in list(range(bp+1))[::-1]:
        b = B_cum[bi]
        if b+a <= K:
            break
    bp = bi
    max_cnt = max(max_cnt, i+bi)

print(max_cnt)

### FIXED CODE ###

import bisect

def main():
    N,M,K = map(int, input().split())
    A_list = list(map(int, input().split()))
    B_list = list(map(int, input().split()))

    # cumsum
    A_cum = [0] * (N+1)
    B_cum = [0] * (M)
    ap = 0
    for i, a in enumerate(A_list):
        A_cum[i+1] = ap + a
        ap += a
    bp = 0
    for i, b in enumerate(B_list):
        B_cum[i] = bp + b
        bp += b

    max_cnt = 0
    for i in range(N+1):
        a = A_cum[i]
        if a > K:
            break
        bi = bisect.bisect_right(B_cum, K-a)
        max_cnt = max(max_cnt, i+bi)

    print(max_cnt)

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

N = int(input())
T, A = [0]*N, [0]*N

for i in range(N):
    T[i], A[i] = map(int, input().split())
ans = T[0]+A[0]

for i in range(N-1):
    for j in range(10**18):
        if (ans+j)%(T[i+1]+A[i+1])==0 and (ans+j)*T[i+1]/(T[i+1]+A[i+1])>=ans*T[i]/(T[i]+A[i]) and (ans+j)*A[i+1]/(T[i+1]+A[i+1])>=ans*A[i]/(T[i]+A[i]):
               ans += j
               break

print(ans)


### FIXED CODE ###

N = int(input())
T, A = [0]*N, [0]*N

for i in range(N):
    T[i], A[i] = map(int, input().split())
t = a = 1
for i in range(N):
    n = max(-(-t//T[i]), -(-a//A[i]))
    t = n*T[i]
    a = n*A[i]
print(t+a)
### BUGGY CODE ###

N = int(input())
a = list(map(int,input().split()))
a_odds = []
a_even = []

for i in range(N):
    if a[i]%2 != 0:
        a_odds.append(a[i])
    else:
        a_even.append(a[i])

a_odds.sort()
a_odds.reverse()
a_even.sort()
a_even.reverse()

count = 0
def judge(a,b):
    n = a+b
    ans = -1
    while(n>0):
        if n==1:
            ans = 0
            break
        elif n%2 == 1:
            ans = 1
            break
        elif n%2 == 0:
            n = n/2
    return ans


while(a_odds!=[]):
    for i in range(len(a_odds)):
        if judge(a_odds[0],a_odds[i])==0 and i!=0:
            count += 1
            a_odds.pop(i)
            break
    a_odds.pop(0)

while(a_even!=[]):
    for i in range(len(a_even)):
        if judge(a_even[0],a_even[i])==0 and i!=0:
            count += 1
            a_even.pop(i)
            break
    a_even.pop(0)


print(count)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
a.sort()
b = {}
for i in range(len(a)):
    if a[i] in b:
        b[a[i]] += 1
    else:
        b[a[i]] = 1
twins = []
now = 1
while now <= a[-1]:
    now *= 2
    twins.append(now)
for i in range(len(a) - 1, -1, -1):
    tmpa = 0
    if  b[a[i]] == 0:
        continue
    for j in range(len(twins) - 1, -1, -1):
        if twins[j] <= a[i]:
            break
        tmpa = twins[j] - a[i]
    if tmpa == a[i]:
        if b[tmpa] >= 2:
            b[tmpa] -= 2
    elif tmpa in b and b[tmpa] != 0:
        b[tmpa] -= 1
        b[a[i]] -= 1
countb = 0
for i in b:
    countb += b[i]
print((n - countb) // 2)
### BUGGY CODE ###

N, M = map( int, input().split())
P = list( map( int, input().split()))
par = [ i for i in range(N)]

def find(x):
    p = par[x]
    if p == x:
        return x
    a = find(p)
#    par[x] = a
    return a

for i in range(M):
    x, y = map( int, input().split())
    x, y = x-1, y-1
    bx, by = find(x), find(y)
    par[y] = bx
    par[by] = bx

ans = 0
for i in range(N):
    if find(i) == find(P[i]-1):
        ans += 1
print(ans)

### FIXED CODE ###

N, M = map( int, input().split())
P = list( map( int, input().split()))
par = [ i for i in range(N)]

def find(x):
    p = par[x]
    if p == x:
        return x
    a = find(p)
    par[x] = a
    return a

for i in range(M):
    x, y = map( int, input().split())
    x, y = x-1, y-1
    bx, by = find(x), find(y)
    par[y] = bx
    par[by] = bx

ans = 0
for i in range(N):
    if find(i) == find(P[i]-1):
        ans += 1
print(ans)
### BUGGY CODE ###

def lcs(x, y):
    a = len(x)
    b = len(y)
    c1 = [0] * (b + 1)
    for i in range(a):
        c2 = c1[:]
        for j in range(b):
            if x[i] == y[j]:
                c1[j+1] = c2[j] + 1
            elif c1[j+1] < c1[j]:
                c1[j+1] = c1[j]
    return c1[-1]
   
n = int(input().rstrip())
ret = []
for i in range(n):
    s1 = input().rstrip()
    s2 = input().rstrip()
    ret.append(lcs(s1, s2))
print(*ret, sep="\n")

### FIXED CODE ###

def lcs(x, y):
    a = len(x)
    b = len(y)
    c1 = [0] * (b + 1)
    for i in range(a):
        e1 = x[i]
        c2 = c1[:]
        for j in range(b):
            if e1 == y[j]:
                c1[j+1] = c2[j] + 1
            elif c1[j+1] < c1[j]:
                c1[j+1] = c1[j]
    return c1[-1]
   
n = int(input().rstrip())
ret = []
for i in range(n):
    s1 = input().rstrip()
    s2 = input().rstrip()
    ret.append(lcs(s1, s2))
print(*ret, sep="\n")