peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n=int(input())
alist=list(map(int,input().split()))
q=int(input())

numdic={}
for i in range(10**5):
    numdic[i+1]=0

for a in alist:
    numdic[a] = numdic[a] + 1
    

outsum=sum(alist)

for i in range(q):
    tmpb,tmpc=map(int,input().split())
    tmp = numdic[tmpb]
    outsum += (tmpc-tmpb)*tmp

    print(outsum)
    
    numdic[tmpb]=0
    numdic[tmpc]=numdic[tmpc]+tmp
# Judge status: Wrong Answer
W, H, N = map(int, input().split())
lis = []
xi = 0
yi = 0
xj = 0
yj = 0
for i in range(N):
    #lis.append(list(map(int, input().split())))
    x, y, a = map(int, input().split())
    if a==1:
        xi += x
    elif a==2:
        xj += x
    elif a==3:
        yi += y
    elif a==4:
        yj += y

x = (W-xj)-xi

if x<0:
    x = 0
y = (H-yj)-yi
if y<0:
    y = 0

print(x*y)
# Judge status: Accepted
N, K = map(int, input().split())
h = []
ans = 1000000000

for i in range(N):
    h.append(int(input()))

h = sorted(h)

for j in range(N-K+1):
    if ans > h[j+K-1]-h[j]:
        ans = h[j+K-1]-h[j]
print(ans)
# Judge status: Wrong Answer
n = int(input())
l1 = 2
l2 = 1
l = 0
for i in range(n-1):
    l = l1+l2
    l1, l2 = l2, l
print(l)
# Judge status: Accepted
N = int(input())
h = list(map(int, input().split())) + [0]*100010

dp = [float("inf")]*100010
dp[0] = 0

for i in range(N):
    dp[i+1] = min(dp[i+1], dp[i] + abs(h[i+1] - h[i]))
    dp[i+2] = min(dp[i+2], dp[i] + abs(h[i+2] - h[i]))
    # print(dp)
print(dp[N-1])
# Judge status: Accepted
N=int(input())
A=int(input())

if (N%500<=A):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N,K = map(int,input().split())
s = [input() for i in range(K*2)]
l = []
c = 0
k = 0
m = 0
# スペース区切りの整数の入力
num = []
for i in range(K*2):
  if i%2==1:
    for m in range(int(s[i-1])):
      num.append(s[i].split()[m])
for j in (1,N+1):
  k=num.count(str(j))
  if k == 0:
    c = c+1
print(c)
# Judge status: Accepted
n,m=map(int,input().split()) 
if 2*n<=m: 
    print(n+(m-2*n)//4) 
else:
    print(m//2)
# Judge status: Accepted
C1 = input()
C2 = input()
ans = "NO"
if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:
    ans = "YES"

print(ans)
# Judge status: Accepted
s = input()

def comb(x):
    return x * (x-1) // 2

left, right = 0, 0
ans = 0
pre = '<'
for c in s:
    if pre == '>' and c == '<':
        ans += comb(min(left, right)) + comb(max(left, right)+1)
        left, right = 1, 0
    elif c == '<':
        left += 1
    else:
        right += 1
    pre = c
ans += comb(min(left, right)) + comb(max(left, right) + 1)
print(ans)
# Judge status: Wrong Answer
X = int(input())
a = X // 500

Y = X - 500 * a
b = Y // 5
print(a)
print(a * 1000 + b * 5)
# Judge status: Accepted
N = int(input())
A = [tuple(map(int, input().split())) for _ in range(N)]

# dp[i][j] i日目にjを選んだ場合の幸福度
dp = [[0]*3 for _ in range(N+1)]

for i, a in enumerate(A):
  for j, h in enumerate(a):
    dp[i+1][j] = max(dp[i][(1+j)%3], dp[i][(2+j)%3]) + h
    
print(max(dp[N]))
# Judge status: Wrong Answer
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
xyc=[list(map(int,input().split())) for i in range(M)]

noti=min(a)+min(b)
ans=0
c=0

for i in range(M):
    c=a[xyc[i][0]-1] + b[xyc[i][1]-1] -xyc[i][2]
    ans=min(noti,c)
print(ans)
# Judge status: Accepted
n = int(input())

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

B = [0 for i in range(n)]
for i in range(n-1):
    B[A[i]-1] += 1
for i in range(n):
    print (B[i])
# Judge status: Wrong Answer
from heapq import heapify, heappop, heappush

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

for i in range(n):
    a[i] *= -1
heapify(a)
print(a)
for i in range(m):
    maxa = heappop(a)
    heappush(a, -(-maxa//2))
print(a)
print(-(sum(a)))
# Judge status: Accepted
n,k=map(int,input().split())
a=list(map(int,input().split()))
n=[0]*200000
x=[]
for i in a:
    n[i-1]+=1
for i in n:
    if i!=0:
        x+=[i]
y=len(x)
z=y-k
if z<=0:
    print(0)
else:
    x.sort()
    print(sum(x[:z]))
# Judge status: Accepted
x, k = map(int, input().split())
print(min(x%k, k - x%k))
# Judge status: Accepted
s = list(input())
t = list(input())
n = len(s)
atoz = [chr(i) for i in range(97, 97+26)]
rs = [-1]*26
rt = [-1]*26
for i in range(n):
  if rs[atoz.index(s[i])] != -1 or rt[atoz.index(t[i])] != -1:
    if rs[atoz.index(s[i])] != t[i] or rt[atoz.index(t[i])] != s[i]:
      print("No")
      break
  else:
    rs[atoz.index(s[i])] = t[i]
    rt[atoz.index(t[i])] = s[i]
else:
  print("Yes")
# Judge status: Wrong Answer
n = int(input())
p = list(map(int,input().split()))

counter = 0


for i in range(n):
    min = p[i]

    for j in range(0,i):
        print("hogeb:"+str(p[j])+"&"+ str(p[i]))
        if min >= p[j]:
            min = p[j]

    if min == p[i]:
        counter += 1

print(str(counter))
# Judge status: Accepted
W,a,b=map(int,input().split())
if b+W<a:
    print(a-(b+W))
elif a+W<b:
    print(b-(a+W))
else:
    print(0)
# Judge status: Accepted
a, b = map(int, input().split())

n = 0
while (a*n-(n-1)) < b:
  n+=1
print(n)
# Judge status: Accepted
n=int(input())
a=[int(input())for _ in range(n)]
b=sorted(a)
max_a=max(a)
second=b[-2]
for i in range(n):
    if a[i] != max_a:
        print(max_a)
    else:
        print(second)
# Judge status: Wrong Answer
a,b = map(int, input().split())
if a < b:
  print(a)
else:
  print(a-1)
# Judge status: Accepted
n = int(input())

count = 0
X = []
for i in range(n):
    x,l = map(int, input().split())
    X.append((x+l,x-l))
X.sort()
coord = -float('inf')

for i in X:
    if i[1] >= coord:
        count += 1
        coord = i[0]
print(count)
# Judge status: Accepted
W,a,b=map(int,input().split())
ans=0
if a+W<b:
    ans=b-(a+W)
elif b+W<a:
    ans=a-(b+W)
print(ans)
# Judge status: Accepted
N = int(input())
list = [int(i) for i in input().split()]

list.sort(reverse = True)
temp = 0
for i in range(N):
  temp += list[1+2*i]

print(temp)
# Judge status: Accepted
s=input()
while True:
    for flag in ["erase","eraser","dream","dreamer"]:
        if s.endswith(flag):
            s=s[:-len(flag)]
            break
    else:
        print("NO")
        break
    if len(s)==0:
        print("YES")
        break
# Judge status: Accepted
P,Q,R=map(int,input().split())
ans=[]
ans.append(P)
ans.append(Q)
ans.append(R)

sorted(ans)
print(P+Q+R-max(ans))
# Judge status: Accepted
N, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0
now = A[0]
if now > x:
    ans += now - x
    now = x
for i in range(1, N):
    if now + A[i] > x:
        y = now + A[i] - x
        ans += y
        A[i] = max(0, A[i] - y)
    now = A[i]
print(ans)
# Judge status: Wrong Answer
n,m=map(int,input().split())

if n<m:
  n,m=m,n
if m==1:
  print(n-2)
elif m==2:
  print(0)
else:
  print((m-2)*(n-2))
# Judge status: Accepted
n = int(input())
p = list(map(int,input().split()))
i = 1
res = 0
while i < n+1:
    if p[i-1] == i:
        res += 1
        i += 1
    i += 1
print(res)
# Judge status: Wrong Answer
n,k = map(int, input().split())

for i in range(n):
  a,b = map(int, input().split())
  k -= b
  if k <= 0:
    print(a)
    exit()
# Judge status: Accepted
MOD = 1000000007
n, a, b = list(map(int, input().split()))

res = pow(2, n, MOD) - 1

dpa = {}
dpb = {}
factriala = 1
factrialb = n
for i in range(1, max(a, b)+1):
  if i in [a, b]:
    dpb[i] = factrialb
  factriala *= i
  factriala %= MOD
  factrialb *= n-i
  factrialb %= MOD
  if i in [a, b]:
    dpa[i] = factriala

def ncr_count(r):
  return dpb[r] * pow(dpa[r], MOD-2, MOD)

res = res - ncr_count(a) - ncr_count(b)

print(res%MOD)
# Judge status: Accepted
#!/usr/bin/env python3
S, C = map(int, input().split())
ret = 0
if 2 * S <= C:
    ret += S
    C -= 2 * S
    S = 0
else:
    ret += C // 2
    S -= C // 2
    C %= 2

ret += C // 4
print(ret)
# Judge status: Wrong Answer
n, m = map(int, input().split())

s = [0] * n
s[0] = 1
b = [1] * n
for i in range(m):
    x, y = map(int, input().split())
    b[x-1] -= 1
    b[y-1] += 1
    if s[x-1] == 1 and s[y-1] == 0:
        s[x-1] = int(b[x-1] != 0)
        s[y-1] = 1

ans = 0
for i in range(n):
    if s[i] and b[i]:
        ans += 1

print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
d_k = set(map(int, input().split()))
ans = n
while ans <= n * 10:
    isOK = True
    for x in range(len(str(ans))):
        if int(str(ans)[x]) in d_k: 
            isOK = False
            break
    if isOK == True: break
    ans += 1
print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
count=0
for i in range(n):
    for j in range(i+1,n):
        for k in range(j+1,n):
            s=[a[i],a[j],a[k]]
            if a[i]!=a[j] and a[i]!=a[k] and a[j]!=a[k]:
                if max(s)<sum(s)-max(s):
                    count+=1
print(count)
# Judge status: Wrong Answer
a, b = map(int, input().split())
if a <= 8 or b <= 8:
  print('Yay!')
else:
  print(':(')
# Judge status: Accepted
N, x = map(int, input().split())
A = list(map(int, input().split()))
ans = 0

# 先頭の箱のキャンディを食べるか否か
if A[0] > x:
	ans += A[0] - x
	A[0] -= A[0] - x
	
flg = 1

while flg:
	flg = 0
	for i in range(1, N):
		adj_box_sum = A[i - 1] + A[i]
		if adj_box_sum > x:
			ans += adj_box_sum - x
			A[i] -= adj_box_sum - x
			if A[i - 1] + A[i] > x:
				flg = 1
print(ans)
# Judge status: Accepted
# -*- coding:utf-8 -*-
N = int(input())
a = list(map(int,input().split()))

L = {}

for i in range(N):
    L[i] = a[i]

sort_L = sorted(L.items(), key=lambda x:x[1])

for j in sort_L:
    print(j[0]+1, end =" ")
# Judge status: Wrong Answer
a, b, c, d = map(int, input().split())

x=0
y=0
if b < 0:
  x=b
else:
  x=a

if d < 0:
  y=d
else:
  y=c

print(x*y)
# Judge status: Accepted
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

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

x = max(A)
A = list(filter(lambda a: a != x, A))
med = x / 2

num = INF
y = 0
for a in A:
    if abs(med - a) < num:
        num = abs(med - a)
        y = a
print(x, y)
# Judge status: Wrong Answer
N=int(input())
if N%2==1:
  a=int(N/2)
  print(a+1)
else:
  b=N/2
  print(b)
# Judge status: Accepted
import numpy as np
n, m = list(map(int,input().split()))
a = list(map(int, input().split()))
a.sort()
bc = [list(map(int,input().split())) for _ in range(m)]
bc.sort(key=lambda x:x[1], reverse=True)

position = 0
counter_ = 0
checker_ = 0
for b,c in bc:
    while  position-counter_ < b and position < n:
        if a[position] < c:
            a[position] = c
            position += 1
        else:
            checker_ = 1
            break
    if checker_:
        break
    counter_ = position
print(sum(a))
# Judge status: Accepted
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))


def solve():
    X = ini()
    ans = 1
    for p in range(2, X):
        a = p * p
        while a <= X:
            ans = max(ans, a)
            a *= p
    return ans


print(solve())
# Judge status: Accepted
import sys
s = input()
a, b, c, k = s.split()

a = int(a)
b = int(b)
c = int(c)
k = int(k)


ans = 0
if k <= a:
	print(k)
	sys.exit()
ans += a
k -= a

if k <= b:
	print(ans)
	sys.exit()
k -= b

print(ans - k)
# Judge status: Accepted
from sys import stdin

n = int(stdin.readline().rstrip())
h = [int(x) for x in stdin.readline().rstrip().split()]

m = 0
count = 0
for i in range(n):
    if i == n - 1:
        if m < count:
            m = count
    else:
        if h[i] >= h[i + 1]:
            count += 1
        else:
            if m < count:
                m = count
            count = 0

print(m)
# Judge status: Wrong Answer
x, a, b = map(int, input().split())
print('A' if abs(x-a)>abs(x-b) else 'B')
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))

dp = [0] * n

dp[1] = abs(h[0] - h[1])

for i in range(2, n):
    dp[i] = min(dp[i-2] + abs(h[i-2] - h[i]), dp[i-1] + abs(h[i-1] - h[i]))

print(dp[-1])
# Judge status: Wrong Answer
k = int(input())
q = [1,2,3,4,5,6,7,8,9]

for i in range(k-1):
	x = q.pop(0)
	if x%10 != 0:
		q.append(10*x + (x%10) -1)
	q.append(10*x + (x%10))
	if x%9 != 0:
		q.append(10*x + (x%10) +1)
		
print(q[0])
# Judge status: Wrong Answer
x, k, d = map(int, input().split())

#x = abs(x)
#0に最も近い距離になる。
ans = x % d
#ansへの移動回数分、kから引く
if k- (x//d) < 0:
    print(x - k*d)
    exit()
else:
    k -= x//d

tmp = abs(ans - d)

if k % 2 == 0:
    print(min(ans, tmp))
else:
    print(max(ans, tmp))
# Judge status: Wrong Answer
import numpy as np
import itertools
N, M, K = map(int, input().split())
Q = [np.asarray(input().split(), dtype=int) for i in range(N)]
min_cost = 10**9
def dfs(cost, C, depth=0):
  global min_cost
  if depth == N:
    return
  if (C >= K).all():
    min_cost = min([cost, min_cost])
    return
  dfs(cost+Q[depth][0], C + Q[depth][1:], depth+1)
  dfs(cost, C, depth+1)
  
dfs(0, np.zeros(M))
    
print(min_cost) if min_cost != 10**9 else print(-1)
# Judge status: Wrong Answer
N,K = map(int,input().split())
j = 0
point = 0
for i in range(1,N+1):
  while (2*i)**j < K:
      j += 1
  point += (1/N)*((1/2)**j)
  i += 1
print(point)
# Judge status: Accepted

N = int(input())

def base(x, n):
  ret = []
  while x != 0:
    ret.append( x % abs(n))
    if n < 0:
      x = - ( (-x)//n )
    else:
      x //= n
  return ret

if N == 0:
  print(0)
else:
  print("".join(map(str, reversed(base(N, -2)))))
# Judge status: Accepted
H = int(input())

def atk(n):
    if n==1: return 1
    return 1 + 2*(atk(n//2))
print(atk(H))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
tmp_money = 1000
tmp_min = A[0]
for i in range(1, N):
    if A[i] <= tmp_min:
        tmp_min = A[i]
    else:
        tmp_kabu = tmp_money // tmp_min
        tmp_money = tmp_money - (tmp_kabu * tmp_min) + tmp_kabu * A[i]
        tmp_min = A[i]
print(tmp_money)
# Judge status: Accepted
N, K = map(int, input().split())

ab = [[0, 0]] * N
for i in range(N):
    _a, _b = map(int, input().split())
    ab[i] = [_a, _b]
ab.sort(key=lambda x:x[0])


total = 0
for pair in ab:
    total += pair[1]
    if total >= K:
        print(pair[0])
        break
# Judge status: Accepted
x, y, z = input().split()
print(z, x, y)
# Judge status: Accepted
N, D = map(int, input().split())
c = 0
for _ in range(N):
  a, b = map(int, input().split())
  if a**2+b**2<=D**2:
    c += 1
print(c)
# Judge status: Accepted
S = input()
if S[-1] == 's':
    print(S+"es")
else:
    print(S+"s")
# Judge status: Wrong Answer
D=int(input())
C=list(map(int,input().split()))
import sys
S=sys.stdin.readlines()
A=[0]*26
B=[0]*D
k=0
for i in range(26):
  if C[i]!=0:
    k+=C[i]
for i in range(26):
  if i<25:
    A[i]=int(C[i]/k*D)
  else:
    A[i]=D-sum(A[:25])

for i in range(25):
  for j in range(A[i]):
    B[(D+1)//(A[i]+1)*j]=i+1

for i in range(D):
  if B[i]==0:
    B[i]=26

print(A)
for i in range(D):
  print(B[i])
# Judge status: Wrong Answer
W,H,N=map(int,input().split())
W0=0
H0=0
for i in range(N):
    x1,y1,a1=map(int,input().split())
    if a1 ==1:
        W0=x1
    elif a1==2:
        W=x1
    elif a1==3:
        H0=y1
    elif a1==4:
        H=y1

if W-W0>0 and H-H0>0:
    print((W-W0)*(H-H0))
else:
    print(0)
# Judge status: Accepted
import sys
def II(): return int(sys.stdin.readline())
def LI(): return list(map(int, sys.stdin.readline().split()))
 
N = II()
A = LI()
 
from collections import Counter
S = Counter(A)
result = sum(list(map(lambda x: int(x*(x-1)/2), S.values())))
 
for a in A:
 n = S[a]
 print(result-n+1)
# Judge status: Wrong Answer
print(1000 - int(input())%1000)
# Judge status: Wrong Answer
def main():
    N, Y = map(int, input().split())

    for i in range(0, N+1):
        for j in range(0, N+1):
            if i * 10000 + j * 5000 + (N-i-j) * 1000 == Y:
                print(i, j, (N-i-j))
                return 
    print(-1, -1, -1)

main()
# Judge status: Wrong Answer
n,k=map(int,input().split())
h=list(map(int,input().split()))
DP=[10**9+1]*n
DP[0]=0
DP[1]=abs(h[1]-h[0])
for i in range(1,n):
    for j in range(max(0,i-k),min(i+1,n-1)):
        DP[i]=min(DP[i],DP[i-j]+abs(h[i]-h[i-j]))
print(DP[-1])
# Judge status: Wrong Answer
n = int(input())
n = n**n
print(round(n))
# Judge status: Wrong Answer
a = list(map(int, input().split()))
b = [0, 0, 0]

b[0] = a[2]
b[1] = a[0]
b[2] = a[1]
print(b)

B = [str(a) for a in b]
B = " ".join(B)
print(B)
# Judge status: Wrong Answer
s = input()
s_list = [s[_] for _ in range(len(s))]

dic = dict()
for c in s_list:
  if c in dic:
    dic[c] += 1
  else:
    dic[c] = 1

flg = True
for key in dic:
  if dic[key] != 2:
    flg = False
    
if flg:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
D = int(input())
c = list(map(int, input().split()))
s = []
for k in range(D):
    s.append(list(map(int, input().split())))

#print(s)
ans = [s[0].index(max(s[0]))+1 for k in range(D)]

for k in range(D):
    print(ans[k])
# Judge status: Accepted
x, y = map(int,input().split())
if x % y == 0:
    print(-1)
else:
    print(x)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n - 1):
    if a[i] == i + 1:
        a[i], a[i + 1] = a[i + 1], a[i]
        ans += 1
    if a[n - 1] == n:
        ans += 1
print(ans)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))

c=0

for i in range(0,n):
  if i%2!=0 or a[i]%2!=0:
    c+=1
print(c)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
ans = 1
re = 0

for i in range(2,N,1):
    #print(re)
    if re == 0:
        if A[i] <= A[i-1] <= A[i-2]:
            re = 0
        elif A[i-2] <= A[i-1] <= A[i]:
            re = 0
        else:
            ans +=1
            re = 1
    else:
        re = 0
            


print(ans)
# Judge status: Accepted
n = int(input())

INF = 1 << 20
dp = [[INF] * (n + 1) for _ in range(3)]

# dp初期化
for i in range(3):
    dp[i][-1] = 0

for i in range(n):
    a, b, c = map(int, input().split())
    dp[0][i] = max(dp[1][i - 1], dp[2][i - 1]) + a
    dp[1][i] = max(dp[2][i - 1], dp[0][i - 1]) + b
    dp[2][i] = max(dp[0][i - 1], dp[1][i - 1]) + c

print(max(list(zip(*dp))[n - 1]))
# Judge status: Wrong Answer
from itertools import accumulate

def main():
    N = int(input())
    people = list(input())

    wests = list(accumulate([0]+people, lambda total, x: total + (1 if x == "W" else 0)))
    easts = list(accumulate([0]+people, lambda total, x: total + (1 if x == "E" else 0)))

    def fullsearch():
        easts_total = easts[-1]
        for i in range(N):
            yield wests[i] + easts_total - easts[i]

    print(min(fullsearch()))

main()
# Judge status: Accepted
import numpy as np
 
n = int(input())
arr = np.array([int(i) for i in input().split()])
mod = 10 ** 9 + 7
ans = 0
 
for i in range(60):
    #一桁目が1か0か調べて1の個数をカウント
    c1 = np.count_nonzero(arr & 1) 
    #1の個数×0の個数(XORだから)
    ans += 2 ** i * c1 * (n - c1)
    #桁をシフト
    arr =arr >> 1

print(ans % mod)
# Judge status: Wrong Answer
N=int(input())
xy=[]
for i in range(N):
    x,y=map(int,input().split())
    xy.append([x,y,x**2+y**2])
xy=sorted(xy,key=lambda x:x[2])
print(abs(xy[0][0]-xy[-1][0])+abs(xy[0][1]-xy[-1][1]))
# Judge status: Accepted
n=int(input())
s=input()
import collections
c = collections.Counter(s)

ans=1
for v in c.values():
    ans*=(v+1)
    ans%=10**9+7
print(ans-1)
# Judge status: Accepted
s = input()

ans = float('inf')
for i in range(len(s)-2):
  n = int(s[i:i+3])
  ans = min(ans, abs(753-n))
print(ans)
# Judge status: Wrong Answer
k = int(input())
a, b = map(int,input().split())
c = b//k
ans=0

for i in range(c):
    i += 1
    ans = i*k
    if a<= ans <=b:
        print("OK")
        break
    else:
        ans = -1

if ans == -1:
    print("NG")
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
yon=0
so=0
flag=False
for i in range(len(a)):
  if a[i]%4==0:
    yon+=1
  elif a[i]%2==0:
    flag=True
  else:
    so+=1
if flag:
  so+=1
if so-1<=yon:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
MOD = 10**9 + 7
S = sum(A) % MOD
ans = (S ** 2) % MOD
for a in A:
    ans -= a**2
    ans %= MOD

ans *= pow(2, MOD-2, MOD)
ans %= MOD
print(ans)
# Judge status: Accepted
a, b, x = map(int, input().split())
if a + b >= x and x >= a:
	print("YES")
else:
	print("NO")
# Judge status: Wrong Answer

a = int(input())
b = 0
while b <= a:
    b = b + 1000

print(abs(a-b))
# Judge status: Wrong Answer
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    ans = solve(n, a)
    print(ans)

def solve(n, a):
    a.sort()
    ans = 0
    ans += sum(a[-(n // 2) - n % 2:])
    ans *= 2
    if n % 2:
        ans -= a[-(n // 2)]
    ans -= a[-1]
    return ans

if __name__ == '__main__':
    main()
# Judge status: Accepted
def main():
    N = int(input())
    L = [int(a) for a in input().split()]
    lmax = max(L)
    L.remove(lmax)
    if sum(L) > lmax :
        print("Yes")
    else:
        print("No")
main()
# Judge status: Accepted
h, w, k = map(int, input().split())
for r in range(h + 1):
    for c in range(w + 1):
        s = (h - r) * c + r * (w - c)
        if s == k:
            print('Yes')
            exit()
print('No')
# Judge status: Wrong Answer
import fractions as fr
import numpy as np
def main():
    N=int(input())
    A=np.array([int(i) for i in input().split()])
    MOD=1000000007
    lcm = 1
    gcd=fr.gcd
    for i in range(N):
        lcm = A[i] * lcm //fr.gcd(A[i], lcm)

    sumval = np.sum(lcm//A)

    print(sumval%MOD)


main()
# Judge status: Wrong Answer
days = int(input())
dp = [[0, 0]]*days
sum = 0
dp[0][0], dp[0][1] = -1, -1
for i in range(days):
    l = list(map(int, input().split()))
    x = max(l)
    y = l.index(x)
    if dp[i-1][0] == y:
        l[y] = 0
        dp[i][1] = max(l)
        dp[i][0] = l.index(dp[i][1])
    else:
        dp[i][1] = max(l)
        dp[i][0] = l.index(dp[i][1])
    sum += dp[i][1]


print(sum)
# Judge status: Wrong Answer
n,m = map(int, input().split())
a = list(map(int, input().split()))
counter = 0
a.sort(reverse=True)

for i in a:
  if i >= int(sum(a) / (4*m)):
    counter =+ 1

print(counter)
if counter >= m:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
import sys

a, b = map(int, sys.stdin.readline().split())

def main():
    print(int(round(a + b) / 2))

if __name__ ==  '__main__':
    main()
# Judge status: Accepted
import itertools
import math

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

ans=0.0
fact=1
for i in range(2,N+1):
    fact*=i

ans=0.0
v=[]
for i in range(N):
    v.append(i)

for s in itertools.permutations(v):
    for j in range(N-1):
        ans+=math.sqrt((XY[s[j]][0]-XY[s[j+1]][0])**2+(XY[s[j]][1]-XY[s[j+1]][1])**2)

print(ans/fact)
# Judge status: Accepted
import math

a, b, h, m = map(int, input().split())
o = 0
c = (h*30) + (m/60*30) - (m*6)
c = math.radians(c)
print(((a**2)+(b**2)-2*a*b*(math.cos(c)))**(1/2))
# Judge status: Accepted
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)] #student
cd=[list(map(int,input().split())) for _ in range(m)] #check point
for i in range(n):
    l=[]
    for j in range(m):
        l.append(abs(ab[i][0]-cd[j][0])+abs(ab[i][1]-cd[j][1]))
    k=l.index(min(l))+1
    print(k)
# Judge status: Wrong Answer
x = int(input())
if x == 30:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
S = input()
s = [S[_] for _ in range(len(S))]
s.sort()

judge = "abcdefghijklmnopqrstuvwxyz"
for i in range(len(s)):
  judge = judge.lstrip(s[i])

if judge == "":
  print("None")
else:
  print(judge[0])
# Judge status: Wrong Answer
c=[list(map(int, input().split())) for i in range(3)]
if (c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2]) and \
   (c[0][1] - c[1][2] == c[1][1] - c[2][1] == c[1][2] - c[2][2]):
    print('Yes')
else:
    print('No')