peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import numpy as np

N, W = map(int, input().split())
dp = np.zeros(W + 1, np.int32)
for _ in range(N):
    w, v = map(int, input().split())
    dp[w:] = np.maximum(dp[w:], dp[:-w] + v)
print(dp[W])
# Judge status: Wrong Answer
import bisect
from itertools import combinations
from collections import Counter
def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    ans = 0
    C = Counter(L)
    for l in combinations(L, 2):
        a = l[0]
        b = l[1]
        x = bisect.bisect_left(L, a + b)
        y = bisect.bisect(L, b - a)
        if b - a < a and a != b:
            ans += x - y - 2
        else:
            ans += x - y  - 1
    print(ans // 3)
if __name__ == "__main__":
    main()
# Judge status: Accepted
N,D=map(int,input().split())
E=2*D+1
print((N+E-1)//E)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))

before = A[0]
is_ascending = None
ans = 0
for a in A:
    d = a - before
    if d == 0:
        pass
    else:
        if is_ascending == None:
            is_ascending = d > 0
        elif (is_ascending and d < 0) or (not is_ascending and d > 0):
            ans += 1
            is_ascending = None
    
    before = a

print(ans+1)
# Judge status: Accepted
N,K = list(map(int,input().split()))
A = list(map(int,input().split()))

for _ in range(min(50,K)):
    lst = [0]*(N+1)
    for i in range(N):
        lst[max(i-A[i],0)] += 1
        lst[min(i+A[i]+1,N)] -= 1
    add = 0
    for i in range(N):
        add += lst[i]
        A[i] = add
print(*A)
# Judge status: Accepted
m = 2019
C = [0]*m
C[0] = 1
s = list(input())
now = 0
cnt = 0
while s:
  now += pow(10, cnt, m) * int(s.pop())
  now %= m
  C[now] += 1
  cnt += 1
ans = 0
for c in C:
  ans += c*(c-1)//2
print(ans)
# Judge status: Accepted
x=int(input())
if x >=400 and 599>=x:
  print("8")
if x >=600 and 799>=x:
  print("7")
if x >=800 and 999>=x:
  print("6")
if x >=1000 and 1199>=x:
  print("5")
if x >=1200 and 1399>=x:
  print("4")
if x >=1400 and 1599>=x:
  print("3")
if x >=1600 and 1799>=x:
  print("2")
if x >=1800:
  print("1")
# Judge status: Wrong Answer
a = [list(map(int, input().split())) for i in range(3)]
aa = list(zip(*a))
n = int(input())
b = [int(input()) for _ in range(n)]
if a[0] in b or a[1] in b or a[2] in b or aa[0] in b or aa[1] in b or aa[2] in b or (a[0][0] in b and a[1][1] in b and a[2][2] in b) or (a[0][2] in b and a[1][1] in b and a[2][0] in b):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import bisect


N = int(input())
L = sorted(map(int, input().split()))
cnt = 0

for i in range(N - 2):
    c = L[i]
    
    for j in range(i + 1, N - 1):
        b = L[j]
        idx = bisect.bisect_left(L, c+b)
        cnt += idx - j - 1
        
print(cnt)
# Judge status: Accepted
n = int(input())
max_1 = 0
max_2 = 0
a_list = []
for i in range(n):
    a = int(input())
    a_list.append(a)
    if max_1 < a:
        max_2 = max_1
        max_1 = a
    elif max_2 < a:
        max_2 = a
#print(max_1,max_2)
for i in range(n):
    if a_list[i] == max_1:
        print(max_2)
    else:
        print(max_1)
# Judge status: Accepted
n = int(input())
*D, = map(int, input().split())
mod = 998244353
if D[0] != 0:
    print(0)
    exit()
C = {}
for d in D:
    try:
        C[d] += 1
    except BaseException:
        C[d] = 1
ans = 1
for d in D[1:]:
    try:
        ans = (ans * C[d - 1]) % mod
    except BaseException:
        ans = 0
print(ans)
# Judge status: Wrong Answer
x,y=map(int,input().split())
mod=10**9+7
def nCr_mod(n,r,mod):
  x=1
  y=1
  for i in range(r):
    x=(x*(n-i)) % mod
    y=(y*(i+1)) % mod
  return (x * pow(y, mod - 2, mod)) % mod
if (x*y)%3!=0:
  print(0)
else:
  m=(2*x-y)//3
  n=(2*y-x)//3
  if m<0 or n<0:
    print(0)
  else:
    print(nCr_mod(m+n,m,mod))
# Judge status: Wrong Answer
N = int(input())
L = map(int,input().split())

L = sorted(L)
sum = 0
for i in range(N):
    sum += L[N + i]
    
print(sum)
# Judge status: Accepted
a, b = map(int, input().split())
ri = b - a
print(ri * (ri + 1) // 2 - b)
# Judge status: Wrong Answer
N = int(input())

a = N //3
b = N//3
print(a*b*(N-a-b))
# Judge status: Wrong Answer
ma=input()
mb=input()
mc=input()
mdic={"a":ma,"b":mb,"c":mc}
m="a"
i=0
ndic={"a":0,"b":0,"c":0}
while ndic[m]<len(mdic[m]):
  m=mdic[m][ndic[m]]
  ndic[m]+=1
print(m.upper())
# Judge status: Accepted
n=int(input())
if(n<10):
  x=n
elif(n<100):
  x=9
elif(n<1000):
  x=n-90
elif(n<10000):
  x=9+900
elif(n<100000):
  x=n-90-9000
elif(n==100000):
  x=90909
print(x)
# Judge status: Wrong Answer
N, K = map(int, input().split())
A = list(map(int, input().split()))

L = [0]*N

for k in range(K):
  for n in range(N):
    a = A[n]
    for i in range(2*a+1):
      p = n - a + i
      if 0 <= p < N:
        L[p] += 1
  A = L
  L = [0]*N
  if k > 41:
    break
    
print(A)
# Judge status: Wrong Answer
n, c, k = map(int, input().split())
T = sorted([int(input()) for _ in range(n)])

cnt = 0
ans = 1
x = T[0] + k

for t in T:
    cnt += 1

    if t > x:
        cnt = 0
        ans += 1
        x = t + k
         
    elif cnt > c:
        cnt = 0
        ans += 1
       
print(ans)
# Judge status: Wrong Answer
import sys

code = input()
for i in range(len(code) - 1):
    if code[i] == code[i + 1]:
        print("Good")
        sys.exit()
print("Bad")
# Judge status: Accepted
n, m = map(int, input().split())

if n == m == 1:
    print(1)
elif n == 1 or m == 1:
    print(max(n, m) - 2)
else:
    print(n * m - (n * 2 + (m - 2) * 2))
# Judge status: Accepted
T = list(str(input()))

for i in range(len(T)):
    if T[i] == "?":
        T[i] = "D"

print(*T, sep="")
# Judge status: Wrong Answer
a,b,c=map(int,input().split())
print(a*b if c%2==1 else 0)
# Judge status: Wrong Answer

K=int(input())

if(K%2==0):
    print(-1)
else:
    seven=7
    seven=seven%K
    ans=1
    for i in range(K+1):
        if(seven==0):
            ans=i+1
            break
        seven=(seven*10+7)%K
    
    print(ans)
# Judge status: Accepted
X, K, D = map(int, input().split())
X = abs(X)
if K * D <= X:
    ans = X - K * D
else:
    k = K - X // D
    if k % 2 == 0:
        ans = X % D
    else:
        ans = abs(X % D - D)
print(ans)
# Judge status: Accepted
def countchar(s) : 
  countstr = [0] * 300
  for i in s : 
    if countstr[ord(i)] != 0 : 
      return False
    countstr[ord(i)] += 1
  return True


s = input()


if countchar(s) : 
  print('yes') 
else : 
  print('no')
# Judge status: Accepted
N, A, B = map(int, input().split())

ans = 0

for n in range(1, N+1, 1):
    l = [i for i in str(n)]
    n_sum = sum(map(int, l))
    if n_sum >= A and n_sum <= B:
        ans += n

print(ans)
# Judge status: Wrong Answer
N, K = map(int, input().split())

print(N % K)
# Judge status: Accepted
a,b = map(int,input().split())
 
if a > 12:
  print(b)
elif a > 5:
  print(b//2)
else:
  print(0)
# Judge status: Accepted
N = int(input())
S = input()
for i in range(N):
    if i == 0:
        num = S[i + 1:].count("E")
        num_min = num
    else:
        if S[i - 1] == "W":
            num += 1
        if S[i] == "E":
            num -= 1
        if num < num_min:
            num_min = num
print(num_min)
# Judge status: Wrong Answer
n = int(input())
a = [int(input()) for _ in range(n)]

a.sort()
ans = 0
flag = True
for i in range(1,n):
    if a[i] == a[i-1]:
        flag = not flag
    else:
        if flag:
            ans += 1
        flag = True
print(ans)
# Judge status: Wrong Answer
s=input()
t=input()
f=False
for i in range(len(t)):
  if s==t[i:]+t[:i]:
    print("Yes")
    break
  if i==len(t):
    print("No")
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

a4, a4n, a2 = 0, 0, 0
for ai in a:
  if ai % 4 == 0:
    a4 += 1
  elif ai % 2 == 0:
    a2 += 1
  else:
    a4n += 1

if a2 != 0:
  print("Yes" if a4 + 1 >= a4n+1 else "No")

else:
  print("Yes" if a4 + 1 >= a4n else "No")
# Judge status: Accepted
n = int(input())
l = []
cnt = 0
for i in range(n):
    x = int(input())
    l.append(x)


x = sorted(l)
i=1
same=1
while i<n:
    if x[i]==x[i-1]:
        same += 1
    else:
        if same%2 == 1:
            cnt += 1
        same = 1
    i += 1

cnt += same%2
print(cnt)
# Judge status: Accepted
s = input()
f = lambda x: '+' if x>0 else '-'
for i in range(-1, 3, 2):
    for j in range(-1, 3, 2):
        for k in range(-1, 3, 2):
            if int(s[0])+i*int(s[1])+j*int(s[2])+k*int(s[3])==7:
                print(s[0]+f(i)+s[1]+f(j)+s[2]+f(k)+s[3]+'=7')
                break
        else:
            continue
        break
    else:
        continue
    break
# Judge status: Accepted
def main():
    C = input()
    AL = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","x","y","z"]
    i = AL.index(C)
    print(AL[i+1])

main()
# Judge status: Accepted
A,B=map(int,input().split())
if A+B<24:
  print(A+B)
else:
  print(A+B-24)
# Judge status: Accepted
import sys
readline = sys.stdin.buffer.readline
read = sys.stdin.buffer.read


N = int(readline())
A = list(map(int, read().rstrip().split()))
A = A[::2]
B = [a for a in A if a % 2 == 1]
print(len(B))
# Judge status: Accepted
s=list(input())
swi=1
if s[0]=="A":
    if "C" in s[2:-1]:
        s=s[1:]
        s.remove("C")
        swi=0
        for i in range(len(s)):
            if not s[i].islower():
                swi=1
print("AC" if swi==0 else "WA")
# Judge status: Accepted
t = sum(map(int, input().split()))
if t % 2 == 0:
        print(t//2)
else:
        print("IMPOSSIBLE")
# Judge status: Accepted
O = input()
#atcoderbeginnercontest

E = input()
#atcoderregularcontest
S = []

if len(O) == len(E):
	for i in range(len(O)):
		S.append(O[i] + E[i])
else:
	for i in range(len(E)):
		S.append(O[i] + E[i])
	S.append(O[-1])
#print(S)
print("".join(S))
# Judge status: Accepted
a,b=map(int,input().split())
if a>=10 or b>=10:
  print(str(-1)+"\n")
else:
  print(str(a*b)+"\n")
# Judge status: Accepted
N, M = [int(i) for i in input().split()]

# S used all C
if 2*N >= M:
    ans = int(M//2)
else:
    ans = N
    M = M - 2*N
    ans += int(M//4)
print(ans)
# Judge status: Wrong Answer

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

possible_c = m
possible_s = n * 2

one_valid = 4 # c

result = (possible_c + possible_s) // one_valid
print (result)
# Judge status: Accepted
N = int(input().rstrip())
judge = []
for _ in range(N):
  hap_lst = list(map(int, input().rstrip().split(' ')))
  if not judge:
    judge = hap_lst
  else:
    a_0, b_0, c_0 = judge
    a_1, b_1, c_1 = hap_lst
    judge = [a_1 + max(b_0, c_0), b_1 + max(a_0, c_0), c_1 + max(a_0, b_0)]
print(max(judge))
# Judge status: Accepted
s = input()
s1 = s[:(len(s)-1)//2]
s2 = s[(len(s)+3)//2-1:]

flag = True
# [:] の指定は　左が閉区間、右が開区間 [ )こんな感じ
if s != s[::-1]:
    flag = False
if s1 != s1[::-1]:
    flag = False
if s2 != s2[::-1]:
    flag = False
print("Yes") if flag else print("No")
# Judge status: Accepted
sx, sy, tx, ty = map(int, input().split())

y = ty - sy
x = tx - sx

u = "U" * y
r = "R" * x
d = "D" * y
l = "L" * x

offset1 = "LU"
offset2 = "RD"
print(u + r + d + l + offset1 + u + r + offset2 + offset2 + d + l + offset1)
# Judge status: Wrong Answer
n = int(input())
a = 1
for i in map(int, input().split()):
    a *= i
if a > 10**18:
    a = -1
print(-1)
# Judge status: Accepted
N = int(input())

hash = {}
for i in range(N):
	key = input()
	if key in hash:
		hash[key] += 1
	else:
		hash[key] = 1
        
max = 0
results = []
for i, v in hash.items():
	if max == v:
		results.append(i)
	elif max < v:
		results = [i]
		max = v

results.sort()
for i in results:
	print(i)
# Judge status: Accepted
import math
import fractions
import sys
#入力:N(int:整数)
def input1():
	return str(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(str,input().split()))


s=list(str(input()))
len_s=len(s)
count=0
for i in range(len_s):
	if s[i]!=s[-(i+1)]:
		s[i]=s[-(i+1)]
		count+=1
	else:
		continue
print(count)
# Judge status: Wrong Answer
import queue
k=int(input())
q=queue.Queue()
for i in range(1,10):
  q.put(i)
c=0
while c<k:
  a=q.get()
  c+=1
  print("{}番目:{}".format(c,a))
  if c==k:
    print(a)
  if (a%10)!=0:
    q.put(10*a+a%10-1)
  q.put(10*a+a%10)
  if (a%10)!=9:
    q.put(10*a+a%10+1)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))

xor_a = 0
for i in range(n):
  xor_a ^= a[i]

print(xor_a)

ans = []
for i in range(n):
  ans.append(a[i] ^ xor_a)

print(*ans)
# Judge status: Accepted
print(["Christmas Eve Eve Eve", "Christmas Eve Eve", "Christmas Eve", "Christmas"][int(input()) - 22])
# Judge status: Accepted
S=input()
N=len(S)

if N%2==0:
  S1="10"*(N//2)
  count=0
  for i in range(N):
    if S[i]==S1[i]:
      count+=1
  if count >= N//2:
    print(N-count)
  else:
    print(count)
else:
  S2="10"*((N-1)//2)+"1"
  count=0
  for i in range(N):
    if S[i]==S2[i]:
      count+=1
  if count >= (N+1)//2:
    print(N-count)
  else:
    print(count)
# Judge status: Accepted
a,b,c,k=map(int,input().split())
print((a-b)*(-1)**k)
# Judge status: Wrong Answer
n = int(input())
list_A = list(map(int, input().split()))

ans = 0
min_value = max(list_A)
for s in list_A:
    if s % 2 == 1:
        ans = 1
        break
    if s <= min_value:
        min_value = s
        ans = s

print(ans)
# Judge status: Accepted
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n,m=map(int,readline().split())

    ans=0
    t=min(n,m//2)
    ans+=t
    n-=t
    m-=2*t
    ans+=m//4
    print(ans)
    
if __name__=="__main__":
    main()
# Judge status: Wrong Answer
A = int(input())
B = int(input())
C = int(input())
X = int(input())

answer = 0
for i in range(A):
  for j in range(B):
    for k in range(C):
      total = 500 * i + 100 * j + 50 * k
      if total == X:
        answer += 1
print(str(answer))
# Judge status: Accepted
N = int(input())
l = map(int, input().split())
res=0
for i, v in enumerate(l):
    if v % 2 == 1 and (i + 1) % 2 == 1:
        res += 1
        
print(res)
# Judge status: Accepted
n,k = list(map(int,input().split()))
cnt=0
while n>0:
    n=n//k
    cnt+=1

print(cnt)
# Judge status: Accepted
n = int(input())
s = {}
for i in range(n):
    a = input()
    if a in s:
        s[a] += 1
    else:
        s[a] = 1
t = {}
m = int(input())
for i in range(m):
    a = input()
    if a in t:
        t[a] += 1
    else:
        t[a] = 1
ans = 0
for i,j in s.items():
    if i in t:
        if j > t[i]:
            ans = max(ans,j-t[i])
    else:
        ans = max(ans,j)
print(ans)
# Judge status: Accepted
a = str(input())
if a == 'AAA' or a == 'BBB':
    print('No')
else:
    print('Yes')
# Judge status: Accepted
print('win' if sum(map(int,input().split())) < 22 else 'bust')
# Judge status: Wrong Answer
n, k = map(int, input().split())
s = input()

see = s[0]
cnt = 0
cluster = 1
for i in range(1, n):
    if see == s[i]:
        cnt += 1
    else:
        see = s[i]
        cluster += 1

for i in range(k):
    if cluster > 2:
        cluster -= 1
        cnt += 2
    else:
        print(n - 1)
        exit()
print(cnt)
# Judge status: Accepted
M, N = map(int, input().split())
result = 0

def fact(num):
    result = 1
    while num > 1:
        result *= num
        num -= 1
    return result

if M!=0 or M!=1:
    result += fact(M) // (fact(2) * fact(M-2))

if N!=0 or N!=1:
    result += fact(N) // (fact(2) * fact(N-2))

print(result)
# Judge status: Wrong Answer
n,m = map(int, input().split())
students = [list(map(int, input().split())) for _ in range(n)]
chkpoints = [list(map(int, input().split())) for _ in range(m)]
dist = 0
ans = 0
for student in students:
  min_dist = 100000000
  for i in range(m):
    dist = abs(student[0]-chkpoints[i][0])+abs(student[1]-chkpoints[i][1])
    if dist < min_dist:
      min_dist = dist
      ans = i+1
  print(ans)
# Judge status: Accepted
A, B, C = map(int,input().split())

for k in range(1,101):
    if (A*k)%B == C:
        print("YES")
        exit(0)
print("NO")
# Judge status: Accepted
import itertools
N, M, Q = map(int, input().split())
q_list = [list(map(int, input().split())) for q in range(Q)]


A_list = list(itertools.combinations_with_replacement(range(1, M+1), N))
ans = 0
for A in A_list:
    # print(A[0])
    sum = 0
    for a, b, c, d in q_list:
        if A[b-1] - A[a-1] == c:
            sum += d
    ans = max(ans, sum)

print(ans)
# Judge status: Wrong Answer
x=input()
if x==("a" or "i" or "u" or "e" or "o"):
    print("vowel")
else:
    print("consonant")
# Judge status: Accepted
s = input()

ans = ''
for c in s:
  if c == 'B':
    if len(ans) >0:
      ans = ans[:-1]
  else:
    ans = ans + c
print(ans)
# Judge status: Wrong Answer
x  = int(input())
if 360 % x == 0:
	print(360//x)
else:
	print((360//x)*5)
# Judge status: Accepted
N=int(input())

luca_list=[2,1]
for i in range(2,N+1):
  luca_list.append(luca_list[-2]+luca_list[-1])
#print(luca_list)
  
print(luca_list[N])
# Judge status: Wrong Answer
import numpy as np
n = int(input())
jousi = list(map(int, input().split()))
a = np.zeros(n)
for i in jousi :
    i = i-1
    a[jousi[i] -1] += 1
for i in range(len(a)):
    print(int(a[i]))
# Judge status: Wrong Answer
x = int(input())
ans = (x//11)*2 if x%11 == 0 else (x//11)*2 + 1 if x%11 <= 5 else (x//11)*2 + 2
print(ans)
# Judge status: Accepted
n = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for _ in range(n):
    word = input()
    if word=='AC':
        c0 +=1
    elif word == 'WA':
        c1 +=1
    elif word == 'TLE':
        c2 +=1
    else:
        c3 +=1
print('AC x '+str(c0))
print('WA x '+str(c1))
print('TLE x '+str(c2))
print('RE x '+str(c3))
# Judge status: Accepted
A,B,K=map(int,input().split())
max=0
min=0
l=[]
if A<B:
    max=B
    min=A
else:
    max=A
    min=B

for i in range(min):
    if (A%(i+1)==0)and(B%(i+1)==0):
        l.append(i+1)
l.sort(reverse=True)
print(l[K-1])
# Judge status: Accepted
import numpy as np


def main():
    N, M = map(int, input().split())
    KA = [list(map(int, input().split())) for _ in range(N)]

    flag = np.array([1]*M)

    for l in KA:
        tmp = np.array([0]*M)
        for i in range(1, l[0]+1):
            tmp[l[i]-1] = 1
        flag *= tmp

    print(sum(flag))


if __name__ == "__main__":
    main()
# Judge status: Accepted
N=int(input())
from numba import*
@njit('i8(i8)',cache=1)
def f(N):
    d=[1]*N
    for i in range(2,N+1):
        for j in range(i-1,N,i):
            d[j]+=1
    r=0
    for i in range(N):
        r+=(i+1)*d[i]
    return r
print(f(N))
# Judge status: Accepted
X = int(input())
t = 1
for t in range(1,X+1):
  total = t*(t+1)/2
  if total>=X:
    break
print(t)
# Judge status: Wrong Answer
a,b,c,d = map(int,input().split())
if abs(a-b) <= d and abs(b-c) <= d:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def mi():
    return map(int, input().split())

def main():
    A, B, K = mi()
    cnt = 0
    for i in range(min(A, B), 0, -1):
        if A%i == 0 and B%i == 0:
            cnt += 1
            if cnt == K:
                print(i)
                return

if __name__ == '__main__':
    main()
# Judge status: Accepted
s = input()
print(2*min(s.count('0'), s.count('1')))
# Judge status: Wrong Answer
n = int(input())
a = n *800
b = int(n/15)
c = b*200
res = a+c
print(res)
# Judge status: Accepted
N = int(input())
N = N-1

P = N//11
K = N%11

if K <= 5:
	count = 1
else:
	count = 2

print(2*P+count)
# Judge status: Accepted
s = input()
if s == "Sunny":
    print("Cloudy")
elif s == "Cloudy":
    print("Rainy")
else:print("Sunny")
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-
import sys

def main():
  alist = [
    "a", "b", "c", "d", "e", "f", "g", "h", "i", "j",
    "k", "l", "m", "n", "o", "p", "q", "r", "s", "t",
    "u", "v", "w", "x", "y", "z",
  ]

  for s in sys.stdin:
    i = 0
    for a in alist:
      if s == a:
        print(alist[i+1])
      i += 1

if __name__ == '__main__':
  main()
# Judge status: Accepted
X = int(input())
c = 0
plus = 1
while c < X:
    c += plus
    plus += 1
print(plus-1)
# Judge status: Accepted
from collections import deque

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

A.sort()
B=deque(A)

U=0
while B:
    _=B.popleft()
    _=B.pop()
    x=B.pop()
    U+=x

print(U)
# Judge status: Accepted
n=int(input())
x=list(map(int,input().split()))
y=sorted(x)
k,l=y[n//2-1],y[n//2]
for i in range(n):
    if x[i]<=k:
        print(l)
    else:
        print(k)
# Judge status: Accepted
N = int(input())
A = map(int, input().split())
Q = int(input())



A = list(A)

hashmap = {}
s = 0
for i in range(len(A)):
	s += A[i]
	hashmap[A[i]] = hashmap.get(A[i], [0, A[i]]) 
	hashmap[A[i]][0] += 1

for _ in range(Q):
	# replace every element whose value is B with C
	B, C = map(int, input().split())

	if B in hashmap:
		num = hashmap[B][0]
		del hashmap[B]
		s -= num * B
		s += num * C

		hashmap[C] = hashmap.get(C, [0, C])
		hashmap[C][0] += num
	print(s)
# Judge status: Accepted
import math
from collections import defaultdict
ml=lambda:map(int,input().split())
ll=lambda:list(map(int,input().split()))
ii=lambda:int(input())
ip=lambda:(input())

"""========main code==============="""
t=ii()
a=ll()
a.sort()
ans=a[0]
for i in range(1,t):
    ans=(ans+a[i])/2
print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-
s = input()
print(len(s)-abs(s.count('0')-s.count('1')))
# Judge status: Accepted
N, M = sorted(map(int, input().split()))
print(0 if 2 in [N, M] else abs(M - 2) if N == 1 else (N - 2) * (M - 2))
# Judge status: Wrong Answer
X,Y= map(int, input().split())
turu = 2
kame = 4
exsist = False
for i in range(0,X+1):
    for j in reversed(range(0,X+1)):
        print(j)
        print(j-i)
        if Y == (turu* (j - i) + kame*j):
            exsist = True
            break

if exsist:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
S = list(input())
count = 0
for i in range(3):
  if S[i] == S[i+1]:
    count += 1
print("Yes" if count > 0 else "No")
# Judge status: Accepted
n = int(input())
count = 0
ans = 0
j = 1

for i in range(1, n+1, 2):
    while j <= i:
        if i % j == 0:
            count += 1
        j += 1
    if count == 8:
        ans += 1
    count = 0
    j = 1
            
print(ans)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

import math

a, b, c = map(int, input().split())

if math.sqrt(a) + math.sqrt(b) < math.sqrt(c):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
li = list(map(int,input().split()))

count = 0

while True:
    success = 0
    i = 0
    for num in li:
        if (num % 2) == 0:
            success += 1
    if(success == N):
        i = 0
        count += 1
        for num in li:
            li[i] = num / 2
            i += 1
    else:
        break
print(count)
# Judge status: Accepted
y, m, d = map(int, input().split('/'))
print('Heisei' if m <= 4 else 'TBD')
# Judge status: Accepted
from collections import Counter

N = int(input())
S = input()

cnter = Counter(S)
alpha = set(cnter)

ans = 1

for i in alpha:
    ans *= (cnter[i] + 1)

print((ans - 1) % (10 ** 9 + 7))
# Judge status: Wrong Answer
N = int(input())
H = input().split(' ')
# print(N)
counter = []
for i in range(1,N):
  # i = 0
  
  while i < N - 1:
    print('aaaa')
    if H[i]>=H[i+1]:
      print('if')
      i+=1
    else:
      counter.append('aa')
      # print('break')
      # break

print(counter)
# Judge status: Accepted
w,h,x,y = map(int, input().split())
ans = w*h/2

if x*2 == w and y*2 == h:
    ans2 = 1
else:
    ans2 = 0

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

a, b = 2, 1
for i in range(n):
    a, b = b, a + b
print(a)
# Judge status: Accepted

N,K = map(int, input().split())
MOD = 10**9+7
def count(N, K):
    min =K*(K-1)/2
    max = (N-K+1)*K+min
    count_num = max-min+1
    K = K +1
    while K <=N+1:
        min = min + K-1
        max = max + N-K+1
        count_num = count_num + max-min+1
        K=K+1
    return count_num

print(int(count(N,K)%MOD))
# Judge status: Wrong Answer
a=int(input())
b=int(input())
print(6-a+b)
# Judge status: Accepted
import sys, math
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
s = lines.pop(0)
k, = [int(num) for num in lines.pop(0).split(" ")]
days = 5000 * (10 ** 12)
for n in s:
    log_k = math.log10(k)
    n = int(n)
    log_n_days = math.log10(n) * days
    if log_k > log_n_days:
        k -= n ** days
    else:
        break
print(n)