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

# coding: utf-8
import itertools
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
d = 0
maxd = 0
for m in range(1, n + 1):
    a0 = [i for i in list(itertools.combinations(list(range(n)), m))]
    for a1 in a0:
        d = sum([v[j] - c[j] for j in a1])
        if maxd < d:
            maxd = d
print(maxd)


### FIXED CODE ###

# coding: utf-8
import itertools
n = int(input())
v = list(map(int, input().split()))
c = list(map(int, input().split()))
d = sum([v[i] - c[i] for i in range(n) if v[i] - c[i] > 0])
print(d)
### BUGGY CODE ###

import bisect
while True:
    N,M=map(int,raw_input().split())
    if N==M==0:break
    L=[input() for i in range(N)]
    L.append(0)
    S=set(i+j for i in L for j in L)
    B=sorted(S)
    maxInt=0
    t=bisect.bisect(B,M)-1
    for i in B[:t]:
        idx=bisect.bisect(B,M-i)
        maxInt=max(maxInt,i+B[idx-1])
    print maxInt

### FIXED CODE ###

import bisect
while True:
    N,M=map(int,raw_input().split())
    if N==M==0:break
    L=[input() for i in range(N)]
    L.append(0)
    S=set(i+j for i in L for j in L)
    B=sorted(S)
    t=bisect.bisect(B,M)-1
    maxInt=max(i+B[bisect.bisect(B,M-i)-1] for i in B[:t])
    print maxInt
### BUGGY CODE ###

import collections,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
dp = [collections.defaultdict(int) for _ in range(N+1)] #1_indexed
dp[0][0] = 0
for i in range(1,N+1):
    w,v = wv[i-1]
    for dw,dv in dp[i-1].items():
        dp[i][dw] = max(dp[i][dw],dv)
        if dw+w<=W:
            dp[i][dw+w] = max(dp[i][dw+w],dv+v)
print(max(dp[-1].values()))


### FIXED CODE ###

import itertools,sys
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
N,W = LI()
wv = [LI() for _ in range(N)]
dp = [[0]*(W+1) for _ in range(N+1)] #1_indexed
for i,j in itertools.product(range(N),range(W+1)):
    w,v = wv[i]
    if j-w>=0:
        dp[i+1][j] = max(dp[i+1][j],dp[i][j-w]+v)
    dp[i+1][j] = max(dp[i+1][j],dp[i][j])
print(dp[-1][-1])
### BUGGY CODE ###

def max2(p, q):
    s = list(set(p+q))
    s.sort(key = lambda x:a[x], reverse = True)
    return s[:2]

n = int(input())
a = list(map(int, input().split()))
g = [[i, (1<<n)] for i in range(1<<n)]
a+=[0]
res = 0
for i in range(n):
    for j in range(1<<n):
        if (1<<i)&j: g[j] = max2(g[j], g[j^(1<<i)])
for i in range(1, 1<<n):
    res = max(res, a[g[i][0]]+a[g[i][1]])
    print(res)

### FIXED CODE ###

def max2(p, q):
    e, b = p[0], p[1]
    c, d = q[0], q[1]
    s = list(set([e, b, c, d]))
    m1, m2 = 1<<n, 1<<n
    for i in s:
        if a[m1]<a[i]:
            m2 = m1
            m1 = i
        elif a[m2]<a[i]:
            m2 = i
    return (m1, m2)

n = int(input())
a = list(map(int, input().split()))
g = [(i, (1<<n)) for i in range(1<<n)]
a+=[0]
res = 0
for i in range(n):
    for j in range(1<<n):
        if (1<<i)&j: g[j] = max2(g[j], g[j^(1<<i)])
ans = []
for i in range(1, 1<<n):
    res = max(res, a[g[i][0]]+a[g[i][1]])
    ans.append(res)
print(*ans, sep = '\n')
### BUGGY CODE ###

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


for i in range(1, N):
  ar.append(abs(sum(A[:i]) - sum(A[i:])))
print(min(ar))

### FIXED CODE ###

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

av = s / 2
x = 0
y = 0

for i in range(N):
  x += A[i]
  
  if x < av < x +A[i+1]:
    
    y = s - x - A[i+1]
    
    if x > y:
      print(A[i+1]-x+y)
      
    else:
      print(A[i+1]-y+x)
  elif x == av:
    print(0)
### BUGGY CODE ###

n=int(input())
s=list(input())
c=0
for i in range(1,n+1):
    for j in range(i+1,n+1):
        for k in range(j+1,n+1):
            if s[i-1]!=s[j-1] and s[k-1]!=s[j-1] and s[i-1]!=s[k-1]:
                if j-i != k-j:
                    c+=1
print(c)

### FIXED CODE ###

N = int(input())
S = input()
 
r = S.count('R')
g = S.count('G')
b = S.count('B')
max = r * g * b 
 
count = 0
for i in range(N-2):
	for j in range(i+1, N-1):
		k = 2 * j - i
		if k > N - 1:
			break
	
		if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
			count += 1
		
		
 
print(max - count)
### BUGGY CODE ###

def main():
    N, Q = map(int, input().split())

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

    for i in range(N-1,-1,-1):
        if tree[i]:
            for j in tree[i]:
                if tree[j]:
                    for k in tree[j]:
                        tree[i].append(k)
    
    ans = [0] * N

    for _ in range(Q):
        p, x = map(int, input().split())
        p -= 1
        ans[p] += x
        for i in tree[p]:
            ans[i] += x

    print(*ans)


main()

### FIXED CODE ###

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

def dfs(v, p, tree, ans):
    for u in tree[v]:
        if u == p:
            continue
        ans[u] += ans[v]
        dfs(u, v, tree, ans)

def main():
    N, Q = map(int, input().split())
    tree = [[] for _ in range(N)]
    for i in range(N - 1):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        tree[a].append(b)
        tree[b].append(a)
    ans = [0] * N
    for i in range(Q):
        p, x = map(int, input().split())
        p -= 1
        ans[p] += x

    dfs(0, -1, tree, ans)

    print(*ans)

main()
### BUGGY CODE ###

def is_prime(q):
    q = abs(q)
    if q == 2: return True
    if q < 2 or q & 1 == 0: return False
    return pow(2, q - 1, q) == 1


def main():
    Q = int(input())
    dp = [-1 for _ in range(1000000)]
    for _ in range(Q):
        cnt = 0
        l, r = map(int, input().split())
        for x in range(l, r + 1):
            if dp[x] != -1:
                if dp[x] == 1:
                    cnt += 1
                    continue

            if is_prime(x) and is_prime((x+1)//2):
                dp[x] = 1
                cnt += 1
            else:
                dp[x] = 0

        print(cnt)

main()


### FIXED CODE ###

def get_prime_array(N):
    f = [0] * (N + 1)
    for i in range(2, N + 1):
        if not f[i]:
            for j in range(i + i, N + 1, i):
                f[j] = 1
    return f


def ans():
    Q = int(input())
    f = get_prime_array(1000001)
    c = [0] * 1000002
    for i in range(3, 1000001, 2):
        if not f[i] and not f[(i + 1) // 2]:
            c[i] += 1

    for i in range(3, 1000000):
        c[i] = c[i] + c[i - 1]

    for _ in range(Q):
        l, r = map(int, input().split())
        print(c[r] - c[l-1])

ans()
### BUGGY CODE ###

from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 0
    for i in range(n):
        tmp = a[:i]
        for j in range(1, int(a[i] ** 0.5) + 1):
            if a[i] % j == 0:
                if j in tmp or (a[i] // j) in tmp:
                    break
        else:
            if not (n > 1 and i < n - 1 and a[i] == a[i + 1]):
                ans += 1
    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


### FIXED CODE ###

from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    max_a = max(a)

    dp = [True] * (max_a + 1)
    ans = 0

    for i in range(n):
        ai = a[i]
        if dp[ai]:
            if not (i < n - 1 and a[i] == a[i + 1]):
                ans += 1
            x = 1
            while ai * x < max_a + 1:
                dp[ai * x] = False
                x += 1

    print(ans)


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

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n, m, k = map(int, input().split())
fr = [0]*n
uf_fr = UnionFind(n)

for i in range(m):
    a, b = map(int, input().split())
    uf_fr.union(a-1, b-1)
    fr[a-1] += 1
    fr[b-1] += 1
for i in range(k):
    c, d = map(int, input().split())
    if uf_fr.find(c-1) == uf_fr.find(d-1):
        fr[c-1] += 1
        fr[d-1] += 1
ans_list = []
for i in range(n):
    ans_list.append(len(uf_fr.members(i)) - fr[i]-1)
print(*ans_list)


### FIXED CODE ###

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


n, m, k = map(int, input().split())
fr = [0]*n
uf_fr = UnionFind(n)

for i in range(m):
    a, b = map(int, input().split())
    uf_fr.union(a-1, b-1)
    fr[a-1] += 1
    fr[b-1] += 1

for i in range(k):
    c, d = map(int, input().split())
    if uf_fr.find(c-1) == uf_fr.find(d-1):
        fr[c-1] += 1
        fr[d-1] += 1

ans_list = []
for i in range(n):
    ans_list.append(uf_fr.size(i) - fr[i] - 1)
print(*ans_list)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
from heapq import heappop,heappush
q=[]
a=0
for i,b in enumerate(B):
    heappush(q,(-b,i))
while len(q)>0:
    b,i=heappop(q)
    if B[i]<A[i]:
        a=-1
        break
    elif B[i]==A[i]:
        continue
    elif B[i]>B[i-1]+B[i+1-N]:
        x=(B[i]-A[i])//(B[i-1]+B[i+1-N])
        if x==0:
            a=-1
            break
        B[i]-=(B[i-1]+B[i+1-N])*x
        heappush(q,(-B[i],i))
        a+=x
    else:
        a=-1
        break
print(a)

### FIXED CODE ###

N=int(input())
A=tuple(map(int,input().split()))
B=list(map(int,input().split()))
from heapq import heappop,heappush
q=[]
a=0
for i,b in enumerate(B):
    heappush(q,(-b,i))
while len(q)>0:
    b,i=heappop(q)
    ba=-b-A[i]
    bb=B[i-1]+B[i+1-N]
    if ba<0:
        a=-1
        break
    elif ba==0:
        continue
    elif -b>bb:
        x,y=divmod(ba,bb)
        if x==0:
            a=-1
            break
        B[i]-=bb*x
        if y>0:
            heappush(q,(-B[i],i))
        a+=x
    else:
        a=-1
        break
print(a)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
"""
Created on Sat Aug 29 22:04:23 2020

@author: liang
"""
def factorization(n):
    arr = set()
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.add(i)

    if temp!=1:
        arr.add(temp)

    if arr=={}:
        arr.add(n)

    return arr

N = int(input())
A = [factorization(int(n)) for n in input().split()]
#print(A)
"""
ans = dict()
isPairwise = True
for st in A:
    for num in st:
        if num in ans.keys():
            ans[num] += 1
            isPairwise = False
            
        else:
            ans[num] = 1
#print(ans)
if isPairwise:
    print("pairwise coprime")
elif any([ans[n] >= N for n in ans.keys()]):
    print("not coprime")
else:
    print("set coprime")
"""

ans2 = set()
count = 0
isPair = True
isSet = False
ans3 = set()
tmp = int()
for st in A:
    for num in st:
        if num in ans2:
            isPair = False
            ans3.add(num)
        ans2.add(num)
    if not isPair:
        break
    count += 1
    if count >= 2:
        isSet = True

isSet = True
for tmp in ans3:
    if all([tmp in A[i] for i in range(N)]):
        isSet = False
    else:
        pass

if count >= 2:
        isSet = True
        
if isPair:
    print("pairwise coprime")
elif isSet:
    print("setwise coprime")
else:
    print("not coprime")

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
Created on Fri Sep 18 07:10:00 2020

@author: liang
"""


# -*- coding: utf-8 -*-
"""
Created on Fri Sep 18 00:26:07 2020

@author: liang
"""

"""
コーナーケース１:
    重複があるとき　not coprime
    ただし、1の重複は除く
"""
import math
C = 10**6
N = int(input())
judge = [False]*(C+1)
A = [int(x) for x in input().split()]

f = True
for a in A:
    if judge[a] == True and a != 1:
        f = False
    judge[int(a)]=True


#print(judge[:10])
def solve(f):
    
    ans = A[0]
    #線形探索 O(N)
    for i in range(N):
        ans = math.gcd(ans,A[i])
    #print("ans",a)
    if ans != 1:
        return "not coprime"
    
    flag = True
    #エラトステネスの篩 O(N log N)
    for i in range(2,C+1):
        count = 0
       #if d[i] == True:
        for j in range(i,C+1,i):
            if judge[j] == True:
                count += 1
            if count == 2:
                flag = False
                break
        #        d[j] = False
        if not flag:
            break
    
    if flag == True and f == True:
        return "pairwise coprime"
    
    return "setwise coprime"

print(solve(f))
#print(len(A))
### BUGGY CODE ###

n,k = map(int,input().split())
p = list(map(int,input().split()))

s = []
s.append(0)
j=0
for i in range(1,1001):
    j+=i
    s.append(j/i)

t = []
for i in p:
    t.append(s[i])

ans = 0
for i in range(n-k+1):
    ans = max(ans,sum(t[i:i+k]))

print(ans)

### FIXED CODE ###

n,k = map(int,input().split())
p = list(map(int,input().split()))

wrk = sum(p[:k])
ans = wrk
for i in range(1,n-k+1):
    wrk-=p[i-1]
    wrk+=p[i+k-1]
    ans = max(ans,wrk)

print(0.5+(0.5*ans)+(k-1)*0.5)
### BUGGY CODE ###

def slove(n, k):
    a_list = sorted([(int(x),i) for i,x in enumerate(k.split())], reverse=True)
    dp = [[0]*(n+1) for i in range(n+1)]
    ans = []
    for i in range(n):
        for j in range(n-i):
            dp[i+1][j] = max(dp[i+1][j],
                         dp[i][j]+a_list[i+j][0]*abs(a_list[i+j][1]-i))
            dp[i][j+1] = max(dp[i][j+1],
                         dp[i][j]+a_list[i+j][0]*abs((n-1-j)-a_list[i+j][1]))
        ans.append(max(dp[i][:-1]))
    return max(ans)

if __name__ == "__main__":
    n = int(input())
    k = input()
    print(slove(n, k))

### FIXED CODE ###

def slove(n, a_list):

    dp = [[0]*(n+1) for i in range(n+1)]
    for i in range(n):
        for j in range(n-i):
            dp[i+1][j] = max(dp[i+1][j],
                         dp[i][j]+a_list[i+j][0]*abs(a_list[i+j][1]-i))
            dp[i][j+1] = max(dp[i][j+1],
                         dp[i][j]+a_list[i+j][0]*abs((n-1-j)-a_list[i+j][1]))

    return max([max(i) for i in dp])

if __name__ == "__main__":
    n = int(input())
    k = sorted([(int(x),i) for i,x in enumerate(input().split())], reverse=True)
    print(slove(n, k))
### BUGGY CODE ###

N = int(input())
a = list(input())
result = N
count = 0
white = [1 if n == '.' else 0 for n in a]
for i in range(N+1):
	count = i-sum(white[0:i])+sum(white[i:N])
	if result > count:
		result = count
print(result)

### FIXED CODE ###

N = int(input())
a = list(input())
result = N
count = 0
result = N
white = [0]*(N+1)
for i in range(N):
	white[i+1] = white[i]
	if a[i] == ".":
		white[i+1] += 1
for i in range(N+1):
    count = i-white[i] + white[N] - white[i]
    if count < result:
        result = count
print(result)
### BUGGY CODE ###

while True:
	a,b,c,d,e = map(int,raw_input().split())
	if a==0:
		break
	na,nb,nc = map(int,raw_input().split())
	v=[0]*(na+nb+nc)
	for i in range(na):
		v[i]=a
	for i in range(nb):
		v[i+na]=b
	for i in range(nc):
		v[i+na+nb]=c
	t=na+nb+nc
	ans=na*a+nb*b+nc*c
	if t < d:
		if ans > d*e:
			ans=d*e
	else:
		tmp = 0
		for i in range(d):
			tmp += v[len(v)-1-i]
		if tmp >= d*e:
			for i in range(len(v)):
				if e < v[i]:
					v[i] = e
			for i in range(d):
				v[len(v)-1-i] = e
		ans=0
		for i in range(len(v)):
			ans += v[i]

	print ans

### FIXED CODE ###

while True:
	a,b,c,d,e = map(int,raw_input().split())
	if a==0:
		break
	na,nb,nc = map(int,raw_input().split())
	t=na+nb+nc
	ans=na*a+nb*b+nc*c
	if t < d:
		if ans > d*e:
			ans=d*e
	else:
		tmp = 0
		dd=d
		cnt=0
		if dd>=nc:
			cnt+=nc*c
			dd-=nc
		else:
			cnt+=dd*c
			dd=0

		if dd>=nb:
			cnt+=nb*b
			dd-=nb
		else:
			cnt+=dd*b
			dd=0

		if dd>=na:
			cnt+=na*a
			dd-=na
		else:
			cnt+=dd*a
			dd=0
		
		if cnt >= d*e:
			if e<a:
				a=e
			if e<b:
				b=e
			if e<c:
				c=e
			dd=d
			cnt=0
			# print "cnt"
			if dd>=nc:
				cnt+=nc*e
				dd-=nc
			else:
				cnt+=dd*e
				cnt+=(nc-dd)*min(e,c)
				dd=0
			# print cnt
			if dd>=nb:
				cnt+=nb*e
				dd-=nb
			else:
				cnt+=dd*e
				cnt+=(nb-dd)*min(e,b)
				dd=0
# 70 100 340 4 200
# 1 1 2
			# print cnt
			if dd>=na:
				cnt+=na*e
				dd-=na
			else:
				cnt+=dd*e
				cnt+=(na-dd)*min(e,a)
				dd=0
			ans=cnt

	print ans
### BUGGY CODE ###

n = int(input())
s = str(input())
s = [str(i) for i in s]
ans = s[1:].count("E")
if ans > s[:n-1].count("W"): ans = s[:n-1].count("W")
for i in range(1, n-1):
    sp = s[:i]
    ss = s[i+1:]
    count = sp.count("W") + ss.count("E")
    if ans > count: ans = count
print(ans)


### FIXED CODE ###

n = int(input())
s = str(input())
s = [str(i) for i in s]
d = int(n/2)
w, e = [], []
w.append(1) if s[0] == "W" else w.append(0)
e.append(1) if s[-1] == "E" else e.append(0)
for i in range(1, n):
    w.append(w[i-1] + 1) if s[i] == "W" else w.append(w[i-1])
    e.append(e[i-1] + 1) if s[n-1-i] == "E" else e.append(e[i-1])
e.reverse()
ans = [w[i-1] + e[i+1] for i in range(1, n-1)]
ans.insert(0, e[0])
ans.insert(-1, w[-1])
print(min(ans))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n = int(input())
A = list(map(int, input().split()))
L = [(a, i) for i, a in enumerate(A)]
L.sort(reverse=True)
dp = dict()
def dfs(l, r):
    i = (n-1-r) + l
    a, idx = L[i]
    if i == n-1:
        res = max(idx-l, r-idx) * a
        return res
    if (l, r) in dp:
        return dp[(l, r)]
    res = max((idx-l)*a + dfs(l+1, r), (r-idx)*a + dfs(l, r-1))
    dp[(l, r)] = res
    return res
ans = dfs(0, n-1)
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n = int(input())
A = list(map(int, input().split()))
L = [(a, i) for i, a in enumerate(A)]
L.sort(reverse=True)
dp = [[-1]*n for _ in range(n)]
def dfs(l, r):
    i = (n-1-r) + l
    a, idx = L[i]
    if i == n-1:
        res = max(idx-l, r-idx) * a
        return res
    if dp[l][r] != -1:
        return dp[l][r]
    res = max((idx-l)*a + dfs(l+1, r), (r-idx)*a + dfs(l, r-1))
    dp[l][r] = res
    return res
ans = dfs(0, n-1)
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(4100000)
input=sys.stdin.readline
# coding: utf-8
# Your code here!

n=int(input())
a = [list(map(int, input().split())) for _ in range(3)]
a[0].sort()
a[2].sort()
"""
print(a[0])
print(a[1])
print(a[2])
"""
def bin_lower(b):
    if a[0][0]>=b:
        return 0
    pl=0
    pr=n-1
    
    while True:
        pc=(pl+pr)//2
        if a[0][pc]>=b and a[0][pc-1]<b:
            return pc
        elif a[0][pc]<b:
            pl=pc+1
            if pl>n-1:
                return n
        """
        else:
            pr=pc-1
            if pr<0:
                return 0
        """
                
def bin_upper(b):    
    if a[2][n-1]<=b:
        return 0
    pl=0
    pr=n-1
    
    while True:
        pc=(pl+pr)//2
        if a[2][pc]<=b and a[2][pc+1]>b:
            return n-1-pc
        elif a[2][pc]>b:
            pr=pc-1
            if pr<0:
                return n
        """
        else:
            pl=pc+1
            if pl>n-1:
                return 0
        """
"""
print(bin_upper(a[1][0]))
print(bin_lower(a[1][0]))
print(bin_upper(a[1][1]))
print(bin_lower(a[1][1]))
print(bin_upper(a[1][2]))
print(bin_lower(a[1][2]))
"""

cnt=0
for i in range(n):
    cnt+=bin_lower(a[1][i])*bin_upper(a[1][i])
print(cnt)


### FIXED CODE ###

import sys
input=sys.stdin.readline
from bisect import bisect_right, bisect_left
n=int(input())
a = [list(map(int, input().split())) for _ in range(3)]
a[0].sort()
a[2].sort()



cnt=0
for i in range(n):
    index_1 = bisect_left(a[0],a[1][i])
    index_2 = n-bisect_right(a[2],a[1][i])
    cnt+=index_1*index_2
print(cnt)
### BUGGY CODE ###

N,X,Y=map(int,input().split())

Ans=[]

i=1
while i<=N:
    j=i+1
    while j<=N:
        Ans.append(min(j-i,abs(X-i)+1+abs(j-Y)))
        j=j+1
    i=i+1

Ans=tuple(Ans)
k=1
while k<=N-1:
    print(Ans.count(k))
    k=k+1

### FIXED CODE ###

N,X,Y=map(int,input().split())

Ans=[0]*N

i=1
d=0
while i<=N:
    j=i+1
    while j<=N:
        d=(min(j-i,abs(X-i)+1+abs(j-Y)))
        Ans[d]+=1
        j+=1
    i+=1

k=1
while k<=N-1:
    print(Ans[k])
    k+=1
### BUGGY CODE ###

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

### FIXED CODE ###

a, b, n = map(int, input().split())
x = min(b-1, n)
s = (a*x) // b - a * (x // b)
print(s)
### BUGGY CODE ###

import numpy as np
A,B,Q=map(int,input().split())
s=[int(input()) for i in range(A)]
t=[int(input()) for i in range(B)]
x=[int(input()) for i in range(Q)]
s=np.array(s)
t=np.array(t)
x=np.array(x)
for X in x:
    l1=min(abs(X-t))
    if -l1 in X-t:
        l1=-l1
    l2=min(abs(X-s))
    if -l2 in X-s:
        l2=-l2
    print(min(abs(l1)+min(abs(X-l1-s)),abs(l2)+min(abs(X-l2-t))))



### FIXED CODE ###

import bisect
INF=10**18
A,B,Q=map(int,input().split())
s=[int(input()) for i in range(A)]
t=[int(input()) for i in range(B)]
s=[-INF]+s+[INF]
t=[-INF]+t+[INF]
for q in range(Q):
    X=int(input())
    t1=bisect.bisect_right(t,X)
    s1=bisect.bisect_right(s,X)
    res=INF
    for T in [t[t1],t[t1-1]]:
        for S in [s[s1],s[s1-1]]:
            ans1=abs(X-T)+abs(S-T)
            ans2=abs(X-S)+abs(S-T)
            res=min(res,ans1,ans2)
    print(res)