peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
import numpy as np
import math
N = int(input())
X = np.array(list(map(int, input().split())))

P_floor = math.floor(np.sum(X)/N)
P_ceil = math.ceil(np.sum(X)/N)

ans = min(np.sum((X-P_floor)**2), np.sum((X-P_ceil)**2))

print(ans)
# Judge status: Accepted
import sys
N,M = map(int,input().split())
if not ( 1 <= N <= 10**12 and 1 <= M <= 10**12 ): sys.exit()

count_SCC=0
if M > 2*N : #Mがあまる
    M = M - 2*N
    count_SCC = N + M//4
elif M < 2*N : #Nがあまる
    count_SCC = M//2
print(count_SCC)
# Judge status: Accepted
n, y = map(int, input().split())

for i in range(n+1):
    for j in range(n+1):
        num_sen = n - i - j
        if num_sen < 0:
            continue

        if 10000 * i + 5000 * j + 1000 * num_sen == y:
            print(i, j, num_sen)
            exit()
print(-1, -1, -1)
# Judge status: Wrong Answer
from collections import deque
x = input()
stack = deque(x[0])
for i in range(1,len(x)):
    if x[i] == "S":
        stack.appendleft(x[i])
    else: #x[i] == "T"
        if len(stack) == 0:
            stack.append(x[i])
        if stack[0] == "T":
            stack.appendleft(x[i])
        else:
            stack.popleft()
print(len(stack))
# Judge status: Accepted
x,y = map(int,input().split())
if y % 2 == 1:
    print("No")
elif 2*x - y/2 < 0:
    print("No")
elif y /2 - x < 0:
    print("No")
else:
    print("Yes")
# Judge status: Accepted
A,B = map(int,input().split())

if A%3==0 or B%3==0 or (A+B)%3==0:
    print("Possible")
else:
    print("Impossible")
# Judge status: Accepted
H, N = map(int, input().split())
A = list(map(int, input().split()))


def answer(H: int, N: int, A: list) -> str:
    damage = 0
    for i in range(0, N):
        damage += int(A[i])
        i += 1
    if damage < H:
        return 'No'
    else:
        return 'Yes'

print(answer(H, N, A))
# Judge status: Accepted
N=int(input())
S=input()
x=0
m=0
for i in range(N):
    if S[i]=='(':
        x+=1
    else:
        x-=1
        m=min(x,m)

a=-m
b=x-m
print('('*a+S+')'*b)
# Judge status: Wrong Answer
a = [int(input()) for _ in range(5)]
z = max(a)
ans = 0
for i in a:
    if i%10!=0:z = min(z,i%10)
    ans += 10*((i+10-1)//10)
print(ans+z-10 if z!=0 else ans)
# Judge status: Wrong Answer
alphabet = 'abcdefghijklmnopqrstuvwxyz'
s = input()
K = int(input())
ans = ''
for i in range(len(s) - 1):
    s_i = alphabet.index(s[i])
    if s_i == 0:
        ans += s[s_i]
        continue
    if 26 - s_i < K:
        K -= 26 - s_i
        s_i = 0
    ans += alphabet[s_i]
s_i = (alphabet.index(s[-1]) + K) % 26
ans += alphabet[s_i]
print(ans)
# Judge status: Accepted
N = int(input())
n, p, score = N, 2, 0
while p ** 2 <= N:
  e = 1
  while n % (p ** e) == 0:
    n //= (p ** e)
    score += 1
    e += 1
  else:
    while n % p == 0:
      n //= p
    p += 2 - (p == 2)
else:
  score += (n > 1)
print(score)
# Judge status: Accepted
import sys
n=int(input())
a=list(map(int,input().split()))
def nibai(n):
  return n*2
a.sort(reverse=True)
sc=a[0]
if n==2:
  print(sc)
  sys.exit() 
a=a[1:]
b=list(map(nibai,a))
sc+=sum(b[:(n//2)-1])
if n%2==0:
  print(sc)
else:
  print(sc+a[(n//2)-1])
# Judge status: Accepted
a, b = map(int, input().split())
diff = abs(a - b)
if diff % 2 == 0:
  print(max(a, b) - diff // 2)
else:
  print('IMPOSSIBLE')
# Judge status: Accepted
N,K=(int(x) for x in input().split())
H = list(map(int, input().split()))

H.sort()

H_= H[:-K]


if N==K:
  print(0)
elif K==0:
  print(sum(H))
else:
  print(sum(H_))
# Judge status: Accepted
n, m = list(map(int, input().split()))

if m >= n * 2:
	x = m - 2 * n
	print(n + x // 4)
    
else:
  print(m // 2)
# Judge status: Accepted
X = int(input())

dp = [0] * (100200)
dp[0] = 1

for i in range(X + 1):
    if dp[i] == 1:
        for j in range(6):
            dp[i + 100 + j] = 1
            if i + 100 + j == X:
                print(1)
                exit()
print(0)
# Judge status: Accepted
a,b = map(int,input().split())

x = int(str(a)+str(b))

for i in range(x):
    if i**2 == x:
        print("Yes")
        break
    elif i**2<x:
        continue
    else:
        print("No")
        break
# Judge status: Accepted
import sys
from math import ceil
def input(): return sys.stdin.readline().strip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    for i in range(K, N):
        if A[i] > A[i - K]:
            print("Yes")
        else:
            print("No")

if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
def LI():
  return [int(s) for s in input().split()]

A,B = LI()

print(A*B)
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))

fin = min(A) == N
for j in range(K):
    if fin:
        break
    T = [0] * (N + 1)
    for i in range(N):
        T[max(i - A[i], 0)] += 1
        T[min(i + A[i] + 1, N)] -= 1
    A[0] = T[0]
    fin = A[0] == N
    for i in range(1, N):
        A[i] = A[i - 1] + T[i]
        if A[i] < N:
            fin = False
print(' '.join(list(map(str, A))))
# Judge status: Accepted
n,x,y=map(int,input().split())
lst=[0]*(n-1)
for i in range(1,n):
  for j in range(i+1,n+1):
    lst[min(j-i,abs(x-i)+1+abs(y-j))-1]+=1
for element in lst:
  print(element)
# Judge status: Accepted
N = int(input())
S = input()

r = S.count('R')
w = 0
ans = [max(r,w)]

for i in range(N):
    if S[i] == 'W':
        w += 1
    else:
        r -= 1
    ans.append(max(w,r))

print(min(ans))
# Judge status: Wrong Answer
n = input()
if n[-1] == '3':
  print('bon')
if n[-1] in ['0','1','6','8']:
  print('pon')
else:
  print('hon')
# Judge status: Accepted
# 必要なキャンディーの個数の合計を出力せよ
# 1からNまでの和はN/2(N+1)で表される

N = int(input())

print(N * (N+1) // 2)
# Judge status: Accepted
n, *a = map(int, open(0).read().split())
res = 1
if 0 in a:
  print(0)
  exit()
for a in a:
  res *= a
  if res > 1e18:
    res = -1
    break
print(res)
# Judge status: Accepted
a = list(input().split(' '))
print(a[2], a[0], a[1])
# Judge status: Wrong Answer
n = int(input())
alis = list(map(int, input().split()))
blis = list(map(int, input().split()))
clis = list(map(int, input().split()))
cache = 0
ans = 0
if n == 2 and alis[0] ==1:
    ans = sum([blis[0] + blis[1] + clis[0]])
else:
    for i in range(n):
        a = alis[i]
        b = blis[a - 1]
        ans += b
        if cache + 1 == a:
            ans += clis[a - 2]
        cache = a
print(ans)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
a=[i for i in A if i%2==0]
b=len([i for i in a if i%3==0 or i%5==0])
if len(a)==b:
    print('APPROVED')
else:
    print('DENIED')
# Judge status: Accepted
print("bust" if sum(list(map(int,input().split())))>=22 else "win")
# Judge status: Accepted
n = int(input())
l = list(map(int,input().split()))
d = {}
for i in l:
    if i in d:
        d[i]+=1
    else:
        d[i] = 1
cp = 0
for i in d.values():
    cp+= i*(i-1)//2
for i in l:
    print(cp-d[i]+1)
# Judge status: Accepted
import math

def main():
    A,B,H,M = [int(x) for x in input().split()]
    degH = (0.5*H*60 + 0.5*M)
    degM = 6*M
    theta = abs(degH-degM)
    if theta == 180:
        print(A+B)
        return
    if theta > 180:
        theta = 180 - (theta - 180)
    # print(degH,degM,theta)
    # print(math.cos(math.radians(theta)))
    print(math.sqrt(A**2 + B**2 - 2*A*B*math.cos(math.radians(theta))))

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
import math
ans=0
A=[int(input()) for i in range(5)]
a=10
for i in range(5):
  if a>(A[i]%10):
    p=i
    a=A[i]
for i in range(5):
  if i==p:
    ans+=A[i]
  else:
    ans+=10*(math.ceil(A[i]/10))
print(ans)
# Judge status: Accepted
# 2020/06/14
# AtCoder Beginner Contest 170 - B

# Input
x, y = map(int,input().split())

# Calc
# i is Tsuru
ans = 'No'
for i in range(0, 101):
    # j is Kame
    for j in range(0, 101):
        if i + j == x and i * 2 + j * 4 == y:
            ans = 'Yes'
            break

# Output
print(ans)
# Judge status: Accepted
n=int(input())
A=list(map(int,input().split()))
ans1=0
ans2=0
A.sort(reverse=True)
flag = False
for i in range(n-1):
  if flag == True:
    flag = False
    continue
  if i < n-1 and A[i+1] == A[i]:
    flag = True
    if A[i] >= ans1:
      ans2 = ans1
      ans1 = A[i]
    elif A[i] > ans2:
      ans2 =A[i]
print(ans1*ans2)
# Judge status: Accepted
n,a,b=map(int,input().split())
print("bust" if n+a+b>=22 else "win")
# Judge status: Accepted
def main():
    n = int(input())
    a = sorted(list(map(int,input().split())),reverse=True)
    ans = a[0]
    for i in range(1,n-1):
        if i%2!=0:
            ans += a[(i+1)//2]
        else:
            ans += a[i//2]
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

P = {}
Q = {}

for i in range(N):
    if i+1 - A[i] in P:
        P[i+1 - A[i]] += 1
    else:
        P[i+1 - A[i]] = 1
    if i+1 + A[i] in Q:
        Q[i+1 + A[i]] += 1
    else:
        Q[i+1 + A[i]] = 1

res = 0
for k,v in P.items():
    if k in Q:
        res += v * Q[k]

print(res)
# Judge status: Wrong Answer
import math

h = int(input())

def f(hp):
    if(hp == 1):
        return 1
    else:
        return (2 * f(math.ceil(hp / 2)) + 1)

print(f(h))
# Judge status: Accepted
D = int(input())
if D == 22:
  print('Christmas Eve Eve Eve')
elif D == 23:
  print('Christmas Eve Eve')
elif D == 24:
  print('Christmas Eve')
else:
  print('Christmas')
# Judge status: Accepted
S = input()
if len(S) % 2 == 1:
  print("No")
else:
  while (len(S) != 0):
    if S[0] == 'h' and S[1] == 'i':
      S = S[2:]
    else:
      break
  if len(S) != 0:
    print("No")
  else:
    print("Yes")
# Judge status: Wrong Answer
A,B=map(int,input().split())

if (A-1)<=B:
	print(A+B)
else:
	 print(A+(A-1))
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

ans = [0 for _ in range(100005)]

for aa in a:
    ans[aa] += 1
    ans[aa+1] += 1
    ans[aa+2] += 1

# prt = 0
# for i,v in enumerate(ans):
#     if v > prt:

print(max(ans))
# Judge status: Accepted
h,m,H,M,k = map(int,input().split())

t1 = 60*h + m
t2 = 60*H + M

ans = t2 - t1 - k
print(ans)
# Judge status: Accepted
s = input()
t = input()

cnt = 0
for i in range(len(s)):
  if s[i] != t[i]:
    cnt += 1

print(cnt)
# Judge status: Wrong Answer
n = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

m = 1+n
for v in prime_factorize(n):
    if v+(n//v)<m:
        m = v+(n//v)

print(m-2)
# Judge status: Accepted
# -*- coding: utf-8 -*-
X, Y = map(int, input().split(' '))
ans = 0
n = X
while n <= Y:
    ans += 1
    n *= 2

print(ans)
# Judge status: Accepted
N = int(input())
N_arr = [int(v) for v in input().split()]  

total_ans = 0
for Ni in N_arr:
  total_ans ^= Ni
for i in range(N):
  ans = total_ans ^ N_arr[i]
  print(ans)
# Judge status: Accepted
N = int(input())
a = sorted(list(map(int,input().split())),reverse=True)

print(sum([a[2*i+1] for i in range(N)]))
# Judge status: Accepted
n=int(input())
csf=[list(map(int,input().split())) for _ in range(n-1)]
for i in range(n):
    t=0
    for j in range(i,n-1):
        c,s,f=csf[j]
        if t<s:
            t=s
        elif t%f>0:
            t+=f-t%f
        t+=c
    print(t)
# Judge status: Accepted
N, K = map(int, input().split())
A = list(map(int, input().split()))


def C(x):
    return sum([max((Ai + x - 1) // x - 1, 0) for Ai in A])


A.sort()
left = 1
right = A[-1]
while left + 1 < right:
    mid = (left + right) // 2
    S = C(mid)
    if S <= K:
        right = mid
    else:
        left = mid
print(left if C(left) <= K else right)
# Judge status: Accepted
n = int(input())
stone = input()
r = stone.count("R")
print(stone.count("W", 0, r))
# Judge status: Accepted
#-------------
N = int(input())
A = list(map(int, input().split()))
#-------------

kabu = 0
money = 1000
for i in range(N-1):
  if A[i] < A[i+1]:
    mod,money = divmod(money , A[i])
    kabu += mod
  if A[i] > A[i+1]:
    money = money + A[i] * kabu
    kabu = 0

money = money + A[N-1]*kabu
print(money)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
monster = 0
hero = 0
for i in range(N):
    allhero = B[i] + hero
    if allhero<=A[i]:
        monster += allhero
        hero = 0
    else:
        monster += A[i]
        if hero>A[i]:
            hero = B[i]
        else:
            hero = allhero-A[i]
    #print(monster,allhero,hero)

if hero>0:
    monster += min(hero,A[N])
print(monster)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))

cnt=0
ans=0

for i in range(n):
    if a[i]<0:
        cnt+=1
        a[i]*=-1

print(a)



if cnt%2==0:
    ans=sum(a)

else:
    ans=sum(a)-2*min(a)

print(ans)
# Judge status: Accepted
a,b,k=map(int,input().split())
if a+k<=b-k:
    for i in range(k):
        print(a+i)
    for i in range(k):
        print(b-k+1+i)
else:
    for i in range(a,b+1):
        print(i)
# Judge status: Accepted
# -*- coding: utf-8 -*-
"""
Created on Tue May 12 00:13:44 2020

@author: shinba
"""
import sys

w,h,x,y = map(int,input().split())

if w%2 == 0 and h%2 == 0:
    if w//2 == x and h//2 == y:
        print((h*w)/2,1)
        sys.exit()
        
print(h*w/2,0)
# Judge status: Accepted
from itertools import combinations_with_replacement

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

ans = 0
for v in combinations_with_replacement(range(1, M+1), N):
    A = list(v)
    temp = 0
    for a, b, c, d in abcd:
        if A[b-1] - A[a-1] == c:
            temp += d
    ans = max(ans, temp)

print(ans)
# Judge status: Accepted
n = input()
n = int(n)
if n % 2 == 0:
    print(int(n/2))
else:
    print(int((n/2)+1))
# Judge status: Accepted
N, M = map(int, input().split())
start = set()
goal = set()

for i in range(M):
    a, b = map(int, input().split())
    if(a == 1):
        start.add(b)
    elif(b == N):
        goal.add(a)
print("IMPOSSIBLE" if(len(start & goal) == 0) else "POSSIBLE")
# Judge status: Accepted
N = int(input())
S = input()
if(S[:N//2] == S[N//2:]):
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
N = int(input())
A = int(input())

b = N%500

if A > b:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a = int(input())
s = input()

if a >= 3200 :
    print(s)
else :
    print("red")
# Judge status: Accepted
import heapq
n, m = map(int, input().split())
price = list(map(lambda x: int(x) * (-1), input().split()))

heapq.heapify(price)
for _ in range(m):
    max_price = -heapq.heappop(price)
    heapq.heappush(price, -(max_price//2))

ans = -sum(price)
print(ans)
# Judge status: Accepted
A, B, C = map(int, input().split())
print('Yes' if A <= C <= B else 'No')
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
dict = {}

for i in range(n):
  if a[i] not in dict:
    dict[a[i]] = 1
  else:
    dict[a[i]] += 1
    
newd = sorted(dict.items())
ans = 0

for j in range(len(dict)-2):
  ans = max(ans,newd[j][1]+newd[j+1][1]+newd[j+2][1])
  
print(ans)
# Judge status: Accepted
n = list(map(int,input().split()))
n =sorted(n)
x = (n[-1])*10+(n[0]+n[1])
print(x)
# Judge status: Wrong Answer
# coding: UTF-8
import sys
import numpy as np
import math


n = int(input())
aList = list(map(int, input().split()))
gcdListLeft = [0 for i in range(n)]
gcdListRight = [0 for i in range(n)]

tmp = aList[0]
for i in range(n):
	gcdListLeft[i] = math.gcd(tmp, aList[i])

tmp = aList[n-1]
for i in range(n-1, -1, -1):
	gcdListRight[i] = math.gcd(tmp,aList[i])

ans = gcdListRight[1]
for i in range(1,n-1):
	ans = max(ans, math.gcd(gcdListLeft[i-1], gcdListRight[i+1]))
ans = max(ans, gcdListLeft[n-2])
print(ans)
# Judge status: Accepted
import collections

n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
s=set()
cnt=collections.Counter(arr)

for i in range(n):
 if arr[i] in s:
   continue
 if cnt[arr[i]]>=2:
   s.add(arr[i])
 for j in range(2,10**6//arr[i]+1):
   s.add(arr[i]*j)
ans=0
for i in range(n):
 if arr[i] in s:
   continue
 ans+=1

print(ans)
# Judge status: Accepted
from itertools import product
n = int(input())
s = input()
ans = s.count('R')*s.count('G')*s.count('B')
for i in range(n-2):
    for j in range(i+1, n):
        k = 2*j-i
        if k <= n-1 and s[i] != s[j] and s[j] != s[k] and s[k] != s[i]: ans -= 1
print(ans)
# Judge status: Accepted
O = input()
E = input()
ans = ''
for i in range(len(E)):
    ans += O[i]
    ans += E[i]
if len(O)-len(E) == 1:
    ans += O[len(O)-1]
print(ans)
# Judge status: Accepted
a, s, c = map(str,input().split())

print("A"+ s[0] +"C")
# Judge status: Wrong Answer
from math import ceil, floor

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

if N == K:
    print(1)
    exit()

idx = 0
for i in range(N):
    if A[i] == 1:
        idx = i
        break

cnt = 0
if idx + 1 == K:
    cnt += 1
else:
    cnt += ceil((idx + 1) / (K - 1))

if N - idx == K:
    cnt += 1
else:
    cnt += ceil((N - idx) / (K - 1))

print(cnt)
# Judge status: Accepted
n,m,X,Y = map(int,input().split())
#print(n,m,X,Y)
x=list(map(int,input().split()))
x.append(X)
y=list(map(int,input().split()))
y.append(Y)
#print(max(x),min(y))
if X < Y:
    if max(x) < min(y):
        print('No War')
    else:
        print('War')
else:
    print('War')
# Judge status: Wrong Answer
N=int(input())
S=input()
T=input()
s=[str(c) for c in (S)]
t=[str(c) for c in (T)]
flag=0
score=N
for i in range (N,2*N+1):
  for j in range(N+N-i):
    flag=0
    if s[i-N+j]!=t[j]:
      flag=1
  if flag==0:
    score=i
    flag=2
  if flag==2:
    break
if flag==1:
  score=2*N
print(score)
# Judge status: Wrong Answer
N,M = map(int, input().split())
print(((N * (N - 1)) / 2 ) + ((M * (M - 1)) / 2 ))
# Judge status: Accepted
n = str(input())
if int(n[-1]) in [2, 4, 5, 7, 9]:
    print('hon')
elif int(n[-1]) in [0, 1, 6, 8]:
    print('pon')
else:
    print('bon')
# Judge status: Wrong Answer
n = int(input())
ans = 0
if n < 10:
  ans += n
else:
  ans += 9
  if n < 1000:
    ans += max(0, n-100)
  else:
    ans += 900
    if n < 100000:
      ans += max(0, n-10000)
    else:
      ans += 90000
print(ans)
# Judge status: Accepted
import collections
n, x, y = map(int, input().split())
d = [[0]*(i+1) for i in range(n)]
x -= 1
y -= 1
for i in range(n):
    for j in range(i+1):
        d[i][j] = min(i-j, abs(x-j)+abs(y-i)+1)
L = []
for i in range(n):
    for dd in d[i]:
        L.append(dd)
C = collections.Counter(L)
for i in range(1, n):
    print(C[i])
# Judge status: Accepted
N,M = map(int,input().split())

def solve(n,m):
  if n == 1 and m == 1:
    return 1
  elif n == 1:
    return m - 2
  elif m == 1:
    return n - 2
  else:
    return (n-2)*(m-2)
  
print(solve(N,M))
# Judge status: Accepted
n = int(input())
n1 = n*800
n2 = n//15
print(n1-(n2*200))
# Judge status: Accepted
N,M=map(int,input().split())
A=list(map(int, input().split()))

r = N-sum(A)
if r < 0:r=-1
print(r)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

S1 = 1

r = input('radius = ')
R = int(r)
S2 = R ** 2

result = S2 / S1
print(int(result))
# Judge status: Accepted
def resolve():
    S = int(input())
    # S == 10 ** 9 * i + mod
    i, mod = divmod(S, 10 ** 9)
    # 求めたいのは、10 ** 9 * i - modなるiとmodの組
    # mod == 0のときはそのまま
    if mod == 0:
        print(0, 0, 10 ** 9, mod, 1, i)
    # そうでないときはiをインクリしてmodの項を負にしてしまえばいい
    else:
        print(0, 0, 10 ** 9, 10 ** 9 * (i + 1) - S, 1, i + 1)


resolve()
# Judge status: Accepted
ln=10**6+10
sieve=[i for i in range(ln)]
p=2
while p**2<=ln:
  if sieve[p]==p:
    for q in range(p*2,ln,p):
      if sieve[q]==q:
        sieve[q]=p
  p+=1
import collections
def primef(n):
  prime_count=collections.Counter()    
  while n>1:
    prime_count[sieve[n]]+=1
    n//=sieve[n]   
  return prime_count
n=int(input())
ans=0
for i in range(1,n):
  t=1
  for j in primef(i).values():
    t=t*(j+1)
  ans+=t
print(ans)
# Judge status: Accepted
N = int(input())
B = list(map(int, input().split()))
ans = 0
ans+=B[0]

for i in range(N-1):
  if i<N-2:
    ans+=min(B[i], B[i+1])
  else:
    ans+=B[N-2]
    
print(ans)
# Judge status: Accepted
N, K = map(int, input().split())

lst = [list(map(int, input().split())) for _ in range(N)]
lst.sort(key=lambda x: x[0])
s = 0
for i in range(N):
	s += lst[i][1]
	if s >= K: break
print(lst[i][0])
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
s = sum(A)
c = 0
d = 10000000000000000
a = 0
for i in range(N):
  c += 2*A[i]
  if abs(c - s) < d:
    a = i
    d = abs(c - s)
a1 = sum(A[:(a+1)])
a2 = sum(A[(a+1):])
ans = abs(a1-a2)
print(ans)
# Judge status: Accepted
n = int(input())
s = input()
ans = 0
for i in range(n-1):
  cnt = 0
  for alp in range(ord('a'),ord('z')+1):
    if chr(alp) in s[:i+1] and chr(alp) in s[i+1:]:
      cnt += 1
  ans = max(ans, cnt)
print(ans)
# Judge status: Wrong Answer
line = input().rstrip().split(" ")
N = [str(i) for i in line]

vote = input().rstrip().split(' ')
V = [str(i) for i in vote]
flag = 0
C = N[0]
for i in range(int(C)):
  if int(V[i]) > (1/(4*int(N[1]))):
    flag = flag + 1
    
if flag >= int(N[1]) :
    print("Yes")
    
else:
    print('No')
# Judge status: Wrong Answer
K,X=map(int,input().split())
M=[]
for i in range (X-K+1,X+K):
  M.append(i)
M.sort()
print(''.join(map(str,M)))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
sum=0
for i in range(2*N):
    if i%2==1:
        sum+=A[i]

print(sum)
# Judge status: Accepted
y, m, d = map(int, input().split('/'))
 
if y < 2019:
	print("Heisei")
elif y == 2019:
	if m < 4 or (m == 4 and d <= 30):
		print("Heisei")
	else:
		print("TBD")
else:
	print("TBD")
# Judge status: Accepted
n = int(input())
a = int(input())

temp = n%500
if temp<=a:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N, M = map(int,input().split())
res = []
for i in range(M):
  if i%2==0:
    j = i//2
    #res.append(M-2*j)
    print("{} {}".format(1+j,M+1-j))
  else:
    j = i//2
    #res.append(M-1-2*j)
    print("{} {}".format(M+2+j,2*M+1-j))
# Judge status: Accepted
K = int(input())
S = input()

if(len(S) <= K):
    print(S)
else:
    for i in range(K):
        print(S[i], end="")
    print("...")
# Judge status: Wrong Answer
n=int(input())
R=[list(input().split()) + [i+1] for i in range(n)]
R.sort(key=lambda x: (x[0],-int(x[1])))
print(R)
for r in R:
    print(r[2])
# Judge status: Wrong Answer
s= raw_input()
m = +float('inf')
for i in range(len(s)):
	if len(s[i:i+3]) ==3: m = min(abs(int(s[i:i+3]) - 753), m)
	if len(s[i:i+4]) ==4: m = min(abs(int(s[i:i+4]) - 753), m)
print m
# Judge status: Accepted
n,m = map(int, input().split())
s, c = [], []
for i in range(m):
    _s, _c = map(int, input().split())
    s.append(_s-1)
    c.append(_c)
 
for i in range(1000):
    *t, = map(int, list(str(i)))
 
    if len(t) != n:
        continue
 
    ok = True
    for j in range(m):
        if t[s[j]] != c[j]:
            ok = False
            break
 
    if ok:
        print(i)
        quit()
 
print(-1)
# Judge status: Accepted
def main():
    X = int(input())

    ans = 1
    for i in range(2, 11):
        for j in range(32):
            if j ** i <= X:
                if j ** i > ans:
                    ans = j ** i

    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
import itertools
import bisect
n = int(input())
a=sorted(list(map(int, input().split())))
b=sorted(list(map(int, input().split())))
c=sorted(list(map(int, input().split())))
cnt=0

for i in range(0,len(b)):
    a_index = bisect.bisect_left(a,b[i])
    c_index = bisect.bisect_right(c,b[i])
    cnt+=a_index*(len(c)-c_index)
    
print(cnt)