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

N = int(input())

l = 0
r = N -1

print(0)
a = input()
if a == 'Vacant':
  exit()
b = a
while r > l:
  i = (r - l)//2
  print(i)
  a = input()
  if a == 'Vacant':
    exit()
  if i%2 == 0:
    if a == b:
      l = i + 1
    else:
      r = i
  else:
    if a == b:
      r = i
    else:
      l = i + 1
  b = a
      
print(l)

### FIXED CODE ###

N = int(input())

l = 0
j = 0
r = N -1

print(0, flush=True)
a = input()
if a == 'Vacant':
  exit()
b = a
while r - l > 1:
  i = (r + l)//2
  print(i, flush=True)
  a = input()
  if a == 'Vacant':
    exit()
  if abs(i-j)%2 == 0:
    if a == b:
      if i > j:
        l = i
      else:
        r = i
    else:
      if i > j:
        r = i
      else:
        l = i
  else:
    if a == b:
      if i > j:
        r = i
      else:
        l = i
    else:
      if i > j:
        l = i
      else:
        r = i
      
  b = a
  j = i

print(l, flush=True)
a = input()
if a == 'Vacant':
  exit()
  
print(r, flush=True)
### BUGGY CODE ###

N = int(input())
p = list(map(int,input().split()))
cou = 0

for i in range(N):
    c = 0
    for j in range(i):
        if p[i] > p[j]:
            c+=1
            break
    if c == 0:
        cou += 1
    
print(cou)
    

### FIXED CODE ###

#41
import math
N = int(input())
p = list(map(int,input().split()))

cou = 0
x = math.inf

for j in range(N):
    if min(x,p[j]) == p[j]:
        x = p[j]
        cou += 1

print(cou)
### BUGGY CODE ###

def calc(left, right, time, vmax):
    if left <= time and time <= right:
        return vmax
    elif time < left:
        return vmax + left - time
    else:
        return vmax + time - right

n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
tlst = [[0, t[0]]]
for i in range(1, n):
    start = tlst[-1][1]
    stop = start + t[i]
    tlst.append([start, stop])

tmax = sum(t)
vnow = 0
ans = 0
for i in range(1, 2*tmax+1):
    time = 0.5 * i
    vmin = 10**9
    for j in range(n):
        left, right = tlst[j][0], tlst[j][1]
        vmax = v[j]
        vmin = min(vmin, calc(left, right, time, vmax))
    vmin = min(vmin, calc(0, 0, time, 0))
    vmin = min(vmin, calc(tmax, tmax, time, 0))
    ans += 0.25 * (vmin + vnow)
    vnow = vmin
print(ans)

### FIXED CODE ###

def calc(left, right, time, vmax):
    if left <= time and time <= right:
        return vmax
    elif time < left:
        return vmax + left - time
    else:
        return vmax + time - right

n = int(input())
t = list(map(int, input().split()))
v = list(map(int, input().split()))
tlst = [[0, t[0]]]
for i in range(1, n):
    start = tlst[-1][1]
    stop = start + t[i]
    tlst.append([start, stop])

tmax = sum(t)
vnow = 0
ans = 0
for i in range(1, 2*tmax+1):
    time = 0.5 * i
    vmin = 10**9
    for j in range(n):
        left, right = tlst[j][0], tlst[j][1]
        vmax = v[j]
        vmin = min(vmin, calc(left, right, time, vmax))
    vmin = min(vmin, calc(0, 0, time, 0))
    vmin = min(vmin, calc(tmax, tmax, time, 0))
    ans += 0.25 * (vmin + vnow)
    vnow = vmin
print(ans)
### BUGGY CODE ###

from math import log10
n = int(input())

ans = 0

for i in range(4, int(log10(n))+2):
    s = n % (10**i)
    while s >= 2019:
        if s % 2019 == 0:
            ans += 1
        s //= 10

print(ans)

### FIXED CODE ###

n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0

for i in range(len(n)):
    temp = (temp+int(n[-i-1])*int(pow(10, i, MOD))) % MOD
    dp[temp] += 1

for item in dp:
    if item > 1:
        ans += item*(item-1)//2

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

import sys
import heapq
input = sys.stdin.readline

n,m = map(int,input().split())
heap = [int(i) for i in input().split()]
heap.sort()

for i in range(m):
  a,b = map(int,input().split())
  for j in range(a):
    if heap[0] < b:
      heapq.heappop(heap)
      heapq.heappush(heap,b)
      
print(sum(heap))

### FIXED CODE ###

import sys
input = sys.stdin.readline

n,m = map(int,input().split())
heap = [int(i) for i in input().split()]
heap.sort()
ans = sum(heap)
ml = []
cnt = 0

for i in range(m):
  a,b = map(int,input().split())
  ml += [[b,a]]
ml.sort(reverse=True)

for i in range(m):
  for j in range(ml[i][1]):
    if ml[i][0] > heap[cnt]:
      ans += ml[i][0] - heap[cnt]
      cnt += 1
      if cnt == n:
        print(ans)
        exit()
    else:
      print(ans)
      exit()
print(ans)
### BUGGY CODE ###

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

def get_sum(a, d, n):
    """ 等差数列の和：(初項a, 公差d, 項数n) """
    return (2*a + (n-1)*d) * n // 2

N = INT()

ans = 0
for i in range(1, N+1):
    cnt = N // i
    ans += get_sum(i, i, cnt)
print(ans)


### FIXED CODE ###

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** -10

def eratosthenes_sieve(n):
    table = [0] * (n+1)
    for i in range(1, n+1):
        for j in range(i, n+1, i):
            table[j] += 1
    return table

N = INT()

res = eratosthenes_sieve(N)
ans = 0
for i in range(1, N+1):
    ans += res[i] * i
print(ans)
### BUGGY CODE ###

def addbit(i):
    i += 1
    while i <= N:
        BIT[i] += 1
        i += i & (-i)
def getsum(i):
    ret = 0
    i += 1
    while i != 0:
        ret += BIT[i]
        i -= i&(-i)
    return ret
def bit(L):
    global BIT
    BIT=[0] * (N+1)
    re = 0
    for l in L:
        re += getsum(l)
        addbit(l)
    return N*(N-1)//2 - re
def calc(Z):
    Z.sort()
    l, r, lc, rc = -1<<28, 1<<28, N*(N-1)//4+1, N*(N-1)//4+1
    f = 1
    while r - l > 0.000000001:
        m = (l+r) / 2 if f else (l * rc + r * lc) / (lc + rc)
        A = [a&((1<<16)-1) for a in sorted([(int((s*m+t)*2**40)<<16)+i for i, (s, t) in enumerate(Z)])]
        c = bit(A)
        if c > N*(N-1)//4:
            l = m
            lc = (c - N*(N-1)//4) * 2
        else:
            r = m
            rc = (N*(N-1)//4 - c) * 2 + 1
        f ^= 1
    return l

N = int(input())
X, Y = [], []
for _ in range(N):
    a, b, c = map(int, input().split())
    X.append((-a/b, c/b))
    Y.append((-b/a, c/a))
print(calc(X), calc(Y))

### FIXED CODE ###

def addbit(i):
    i += 1
    while i <= N:
        BIT[i] += 1
        i += i & (-i)
def getsum(i):
    ret = 0
    i += 1
    while i != 0:
        ret += BIT[i]
        i -= i&(-i)
    return ret
def bit(L):
    global BIT
    BIT=[0] * (N+1)
    re = 0
    for l in L:
        re += getsum(l)
        addbit(l)
    return N*(N-1)//2 - re
def calc(Z):
    Z.sort()
    l, r, lc, rc = -1<<28, 1<<28, N*(N-1)//4+1, N*(N-1)//4+1
    f = 1
    while (r - l) / max(abs(l), 1) > 0.000000001:
        m = (l+r) / 2 if f else (l * rc + r * lc) / (lc + rc)
        A = [a&((1<<16)-1) for a in sorted([(int((s*m+t)*2**40)<<16)+i for i, (s, t) in enumerate(Z)])]
        c = bit(A)
        if c > N*(N-1)//4:
            l = m
            lc = (c - N*(N-1)//4) * 2
        else:
            r = m
            rc = (N*(N-1)//4 - c) * 2 + 1
        f ^= 1
    return l

N = int(input())
X, Y = [], []
for _ in range(N):
    a, b, c = map(int, input().split())
    X.append((-a/b, c/b))
    Y.append((-b/a, c/a))
print(calc(X), calc(Y))
### BUGGY CODE ###

S = input()
N = len(S)
S = int(S, 2)
a = ""
b = ""
for n in range(N):
	if n%2 ==0:
		a += '1'
		b += '0'
	else:
		a += '0'
		b += '1'
a = int(a, 2)
b = int(b, 2)
a = a ^ S
b = b ^ S
at = 0
bt = 0
for n in range(N):
	at += a%2
	bt += b%2
	a //= 2
	b //= 2
print(min(at, bt))

### FIXED CODE ###

S = input()
N = len(S)
t0, t1 = 0, 1
a = 0
b = 0
for s in S:
	if s == "1":
		a += t0
	else:
		a += t1
	t0, t1 = t1, t0
print(min(a,N-a))
### BUGGY CODE ###

n = input()
a = list(map(int, input().split()))
ans = 'YES'
b = []
for i in a:
    if i in b:
        ans = 'NO'
    else:
        b.append(i)
print(ans)

### FIXED CODE ###

n = input()
a = list(map(int, input().split()))
def has_duplicates(seq):
    return len(seq) != len(set(seq))
if has_duplicates(a):
    print('NO')
else:
    print('YES')
### BUGGY CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

h,w = na()
dp = []
for i in range(h):
    s = ns()
    c = 0
    lst = []
    for j in s:
        if j == '.':
            c += 1
        else:
            for k in range(c):
                lst.append(c)
            lst.append(0)
            c = 0
    for k in range(c):
        lst.append(c)
    dp.append(lst)

ans = 0
for i in range(w):
    a = 0
    c = 0
    for j in range(h):
        t = dp[j][i]
        if t == 0:
            a = max(t,a)
            ans = max(ans,a+c)
            a = 0
            c = 0
        else:
            a = max(t,a)
            c += 1
    ans = max(ans,a+c)

print(ans-1)

### FIXED CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

h,w = na()
dp = []
for i in range(h):
    s = ns()
    c = 0
    lst = []
    for j in s:
        if j == '.':
            c += 1
        else:
            for k in range(c):
                lst.append(c)
            lst.append(0)
            c = 0
    for k in range(c):
        lst.append(c)
    dp.append(lst)

ans = 0
for i in range(w):
    a = 0
    c = 0
    for j in range(h):
        t = dp[j][i]
        if t == 0:
            a = max(t,a)
            ans = max(ans,a+c)
            a = 0
            c = 0
        else:
            a = max(t,a)
            c += 1
    ans = max(ans,a+c)

print(ans-1)
### BUGGY CODE ###

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

def main():
  ans = 0
  for i in range(n):
    for j in range(n):
      if a[i] % a[j] == 0 and i != j:
        ans += 1
        break
  print(n-ans)

main()

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
kmax = sorted(a)[-1]
c = [0]*(kmax+1)

for i in range(n):
  c[a[i]] -= 1
  for j in range(a[i],(kmax+1),a[i]):
    c[j] += 2

ans=c.count(1)
print(ans)
### BUGGY CODE ###

def pow(a,b,M):
    if b == 0:
        return 1
    elif b % 2 == 0:
        return pow((a**2)%M,b//2,M) % M
    else:
        return ((a % M) * pow((a**2)%M,b//2,M)) % M

def cmb(a,b,c):
    b = min(b,a-b)
    num = 1
    for i in range(b):
        num = num*(a-i) % c
    den = 1
    for i in range(b):
        den = den*(i+1) % c
    return num * pow(den,c-2,c) % c

mod = 10**9+7
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
ans = 0
c = cmb(n-1,k-1,mod)
if k == 1:
    print(0)
    exit()
for i in range(n-k+1):
    ans -= a[i] * c
    ans += a[-i-1] * c
    ans %= mod
    c = c * (n-k-i) * pow(n-i-1,mod-2,mod)
if ans < 0:
    ans += mod
print(ans)


### FIXED CODE ###

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

M = 10**9+7

def pow(a,b,M):
    if b == 0:
        return 1
    elif b % 2 == 0:
        return pow((a**2)%M,b//2,M) % M
    else:
        return ((a % M) * pow((a**2)%M,b//2,M)) % M

def inv(a,p):
    return pow(a,p-2,p)

ans,comb = 0,1
#i番目ではcomb = (K-1-i)_C_(K-1)
#max,min以外での選ぶ個数は常にK-1であることに注目すればcomb関数はいらなかった
for i in range(N-K+1):
    if i > 0:
        comb = (comb * (K-1+i) * inv(i,M)) % M
    ans = (ans + comb*((A[K-1+i]-A[N-K-i]) % M)) % M
print(ans)
### BUGGY CODE ###

import sys
import numpy as np 
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix
from itertools import combinations


n = int(sys.stdin.readline().rstrip())
A = np.array(sys.stdin.read().split(), dtype=np.int64).reshape(n, n)

def main():
    B = floyd_warshall(A, directed=False)
    if np.any(A - B > 0):
        return -1

    will_subtract = []
    for v, u in combinations(range(n), 2):
        d = B[v, u]
        for w in range(n):
            if w != v and w != u:
                if B[v, w] + B[w, u] == d:
                    will_subtract.append(d)
    
    ans = np.sum(B) // 2 - sum(will_subtract)
    return int(ans)

if __name__ == '__main__':
    ans = main()
    print(ans)

### FIXED CODE ###

import sys
import numpy as np 
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import csr_matrix

n = int(sys.stdin.readline().rstrip())
A = np.array(sys.stdin.read().split(), dtype=np.float64).reshape(n, n)

def main():
    B = floyd_warshall(csr_matrix(A), directed=False).astype(np.int64)
    if np.any(B < A):
        return -1
        
    np.fill_diagonal(A, np.inf)
    
    total_length = 0
    for v in range(n-1):
        for u in range(v+1, n):
            detours = A[v] + A[u]
            if np.all(detours > B[v, u]):
                total_length += B[v, u]

    return total_length

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

n = int(input())
l = list(map(int, input().split()))
l.sort(reverse=True)
count = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      if l[i] < l[j]+l[k]:
        count += 1
      else:
        break

print(count)

### FIXED CODE ###

import bisect

n = int(input())
l = sorted(list(map(int, input().split())))
count = 0
for b in range(n-2):
  for c in range(b+1, n-1):
    count += max(0, bisect.bisect_left(l, l[b]+l[c])-c-1)

print(count)
### BUGGY CODE ###

n, q = list(map(int, input().split()))
s = input().split()[0]
lr_list = []

for _ in range(q):
    l, r = list(map(int, input().split()))
    lr_list.append((l, r))

for l, r in lr_list:
    sub_s = s[l-1:r]
    count = sub_s.count('AC')
    print(count)


### FIXED CODE ###

n, q = list(map(int, input().split()))
s = input().split()[0]
lr_list = [list(map(int, input().split())) for _ in range(q)]

count_ac_list = [0] * n
for i in range(n-1):
    # print('{}: {}'.format(i, s[i:i+2]))
    if s[i:i+2] == 'AC':
        count_ac_list[i+1] = count_ac_list[i] + 1
    else:
        count_ac_list[i+1] = count_ac_list[i]

count_list = [str(count_ac_list[r-1] - count_ac_list[l-1]) for l, r in lr_list]

print('\n'.join(count_list))
### BUGGY CODE ###

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

l = -1
r = -1

for k in range(K):
    for i in range(1, N):
        if S[i] != S[i-1]:
            if l < 0:
                l = i
            else:
                r = i
                for s in range(l, r):
                    if S[s] == "L":
                        S[s] = "R"
                    else:
                        S[s] = "L"
                l = -1
                r = -1
                break
        elif i == N-1 and l >= 0:
            for s in range(l, N):
                if S[s] == "L":
                    S[s] = "R"
                else:
                    S[s] = "L"
            l = -1
            break
ans = 0
for i in range(1, N):
    if S[i] == S[i-1]:
        ans += 1

print(ans)


### FIXED CODE ###

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

l = -1
r = -1

k = 0
while k < K:
    for i in range(1, N):
        #print(i, l, "l")
        if S[i] != S[i-1]:
            if l < 0:
                l = i
            else:
                #print("a", l, i)
                r = i
                for s in range(l, r):
                    if S[s] == "L":
                        S[s] = "R"
                    else:
                        S[s] = "L"
                l = -1
                r = -1
                k += 1
                if k == K:
                    break
    l = -1
    r = -1
    # elif i == N-1 and l >= 0:
    #     for s in range(l, N):
    #         if S[s] == "L":
    #             S[s] = "R"
    #         else:
    #             S[s] = "L"
    #     l = -1
    #     k += 1
    #     if k == K:
    #         break
    if l < 0:
        break
ans = 0
#print(len(set(S)), k, K)
if len(set(S)) == 2 and k < K:
    ans += 1
for i in range(1, N):
    if S[i] == S[i-1]:
        ans += 1
# print(S)
print(ans)
### BUGGY CODE ###

n = int(input())
power = 1
for i in range(1,n+1):
    power *= i%(10**9+7)
print(power % (10**9 + 7))


### FIXED CODE ###

n = int(input())
power = 1
for i in range(1,n+1):
    power = (i*power)%(10**9+7)
print(power)
### BUGGY CODE ###

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

dp = [0] * N
for i in range(1, N):
    hi = hs[i]
    dp2 = dp[max(0, i-K):i]
    costs = [abs(h - hi) for h in hs[max(0, i-K):i]]
    dp[i] = min([dpj + cost for dpj, cost in zip(dp2, costs)])

print(dp[N-1])


### FIXED CODE ###

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

dp = [0] * N
for i in range(1, N):
    hi = hs[i]
    dp2 = dp[max(0, i-K):i]
    costs = [abs(h - hi) for h in hs[max(0, i-K):i]]
    dp[i] = min([dpj + cost for dpj, cost in zip(dp2, costs)])

print(dp[N-1])
### BUGGY CODE ###

n= int(input())
s = input()

total = 0
for i in range(0,n-2):
    for j in range(i+1,n-1):
        if s[i] == s[j] :
            continue
        for k in range(j+1,n):
            if  s[i] != s[k] and s[j] != s[k]:
                if j!= (k+i)/2:
                    # if j<3:
                        # print(i,j,k)
                    total += 1
print(total)

### FIXED CODE ###

n = int(input())
s = input()
a = []
for i in range(n):
    if s[i] == 'R' :
         a.append(0)
    if s[i] == 'G' :
         a.append(1)
    if s[i] == 'B' :
         a.append(2)
cnt = [0,0,0]
for i in range(n):
    cnt[a[i]] +=1
ans = 1

for i in range(3):
    ans *= cnt[i]
# print(a)
for i in range(n):
    for j in range(i+1,n):
        k = j+(j-i)
        if k<n:
            if a[i] != a[j] and  a[i] != a[k]and a[k] != a[j]:
                # print(i,j,k,a[i],a[j],a[k])
                ans -=1



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

# -*- coding: utf-8 -*-
import heapq


num_product, num_coupon = [int(s) for s in input().split()]
price_list = []
for s in input().split():
  heapq.heappush(price_list, int(s))

for i in range(num_coupon):
  max_price = max(price_list)
  for j in range(len(price_list)):
    if price_list[j] == max_price:
      price_list[j] //= 2
      break

sum = 0
for price in price_list:
  sum += price

print(sum)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import heapq

num_product, num_coupon = [int(s) for s in input().split()]
price_list = []
for s in input().split():
  heapq.heappush(price_list, int(s)*-1)

for i in range(num_coupon):
  min = price_list[0]
  heapq.heapreplace(price_list, (min*-1//2)*-1)

sum = 0
for price in price_list:
  sum -= price

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

from math import floor
a,b,n = map(int,input().split())
if a == 1:
    print(0)
    exit()

prev = 0
for x in range(1,n+1):
    val = floor(a*x/b) - a*floor(x/b)
    if val < prev:
        print(prev)
        exit()
    prev = val
print(prev)


### FIXED CODE ###

from math import floor
a,b,n = map(int,input().split())
if a == 1 or b == 1:
    print(0)
    exit()

prev = 0

for x in range(min(b-1,n),n+1, b):
    val = floor(a*x/b) - a*floor(x/b)
    if val < prev:
        print(prev)
        exit()
    prev = val

val = floor(a*n/b) - a*floor(n/b)
print(max(prev,val))
### BUGGY CODE ###

import copy
N = int(input())

A = [0]*N

for r in range(N):
  A[r] = int(input())
Elias_A = copy.copy(A)
A.sort()
Sorted_A = copy.copy(A)
  
for r in range(N):
  A.remove(Elias_A[r])
  print(A[N-2])
  A = copy.copy(Sorted_A)

### FIXED CODE ###

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

for r in range(N): A[r] = int(input())
A_max = max(A)
A_sec = sorted(A)[-2]

for r in range(N):
  if A[r] == A_max: print(A_sec)
  elif A[r] == A_sec: print(A_max)
  else: print(A_max)
### BUGGY CODE ###

def binarySearch(list_a, key):
    left = 0
    right = len(list_a)
    while left < right:
        mid = (left + right) // 2
        if key < list_a[mid]:
            right = mid
        else:
            left = mid+1
    else:
        return left


n = int(input())
list_a = list(map(int, input().split()))
list_b = list(map(int, input().split()))
list_c = list(map(int, input().split()))
list_a.sort()
list_b.sort()
list_c.sort()
count = 0
for c in list_c:
    for b in list_b[:binarySearch(list_b, c-0.5)]:
        count += binarySearch(list_a, b-0.5)
print(count)

### FIXED CODE ###

n = int(input())
list_a = list(map(int, input().split()))
list_b = list(map(int, input().split()))
list_c = list(map(int, input().split()))
list_a.sort()
list_b.sort()
list_c.sort()
list_a.append(10**10)
list_b.append(10**10)
list_c.append(10**10)

list_memo = []
i = 0
j = 0
k = 0
start = 0
list_ans = []
a_count = 0
while k < n:
    if list_c[k] == min(list_a[i], list_b[j], list_c[k]):
        list_memo.append(0)
        list_memo[-1] = sum(list_memo[start:-1])
        list_ans.append(list_memo[-1])
        start = len(list_memo) - 1
        k += 1
    elif list_b[j] == min(list_a[i], list_b[j], list_c[k]):
        list_memo.append(a_count)
        j += 1
    else:
        list_memo.append(0)
        a_count += 1
        i += 1
print(sum(list_ans))
### BUGGY CODE ###

def main():
    N = int(input())
    A = sorted(list(map(int, input().split())), reverse=True)
    ans = A.pop(0)
    for i in range(N - 2):
        if i%2 == 0:
            x = A.pop(0)
        ans += x
    print(ans)
            
if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import deque
def main():
    N = int(input())
    A = deque(sorted(list(map(int, input().split()))))
    ans = A.pop()
    for i in range(N - 2):
        if i%2 == 0:
            x = A.pop()
        ans += x
    print(ans)
            
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def main():
    S = input()[:-1]
    Q = int(input())
    li = ['' for _ in range(2)]
    now = 0
    for _ in range(Q):
        x = input()
        if(x[0] == '2'):
            if(x[2]=='1'):
                li[1-now] += x[4]
            else:
                li[now] += x[4]
        else:
            now = 1-now

    print(li[1-now][::-1]+S[::-(now*2-1)]+li[now])
    

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    S = input()[:-1]
    Q = int(input())
    li = [[] for _ in range(2)]
    now = 0
    for _ in range(Q):
        x = input()
        if(x[0] == '2'):
            if(x[2]=='1'):
                li[1-now].append(x[4])
            else:
                li[now].append(x[4])
        else:
            now = 1-now

    s = ''.join(li[1-now][::-1]) + S[::-(now*2-1)] + ''.join(li[now])
    print(s)

if __name__ == '__main__':
    main()