peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
#!/usr/bin/env python

def main():
    n = int(input())
    a = list(map(int, input().split()))
    mod = 10 ** 9 + 7

    ret = 0
    magni = 1
    for j in range(60):
        bin_cnt = [0, 0]
        for i in range(n):
            a[i], b = divmod(a[i], 2)
            bin_cnt[b] += 1
        x, y = bin_cnt
        ret += x * y * magni % mod
        magni = magni * 2 % mod

    ret %= mod

    print(ret)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N, M = map(int, input().split())
print(N*M-M)
# Judge status: Accepted
a, b, c = map(int, input().split())
print("YES" if b - a == c - b else "NO")
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
M = 10**9 + 7

S = sum(A)
S2 = sum(map(lambda x: x**2, A))
print(((S**2 - S2)// 2)%M)
# Judge status: Wrong Answer
n = int(input())

if n % 2 == 0:
    print(n // 2)
    print(1)
    print(n // 2 - 1)
else:
    print(n // 2 + 1)
    print(n - (n // 2 + 1))
# Judge status: Accepted
from collections import Counter

P = 998244353
N = int(input())
D = [int(x) for x in input().split()]

def solve():
  if D[0] != 0:
    return 0
  total = 1
  max_d = max(D)
  counter = Counter(D)
  if counter[0] != 1:
    return 0
  for i in range(max_d + 1):
    if i not in counter:
      return 0
    if i > 1:
      total *= (counter[i - 1] ** counter[i] % P)
      total %= P
  return total

print(solve())
# Judge status: Wrong Answer

N = int(input())
for i in range(1, N):
    if i*i > N:
        print((i-1)*(i-1))
        exit()
print(0)
# Judge status: Accepted
import math

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

if x==a**2*b:
    print(0)
    exit()

if a**2*b/2<=x:
    ans = 90-math.degrees(math.atan(a**3/2/(a**2*b-x)))
else:
    ans = 90-math.degrees(math.atan(2*x/a/b**2))
print(ans)
# Judge status: Accepted
import heapq
n,m = map(int,input().split())
a = list(map(lambda x: int(x)*(-1),input().split()))
a.sort(reverse=True)
heapq.heapify(a)
for i in range(m):
    x = -heapq.heappop(a)
    x //= 2
    heapq.heappush(a,-x)
print(-sum(a))
# Judge status: Wrong Answer
[n,m,x,y] = [int(i) for i in input().split()]

xs = [int(i) for i in input().split()]
ys = [int(i) for i in input().split()]

checker = 0

for i in range(x+1,y+1):
    #print(max(xs),i,min(ys))
    if max(xs) < i and min(ys) >= i:
        checker = 1
if checker:
    print("No war")
else:
    print("War")
# Judge status: Accepted
N, M, *_ = map(int, open(0).read().split())

A = []
K_i = 0
for i in range(N):
    K = _[K_i]
    A.append(_[K_i+1 :  K_i+1+K])
    K_i += K + 1
    
ans = 0

for m in range(1, M+1):
    for k, a_i in enumerate(A, start=1):
        if m not in a_i:
            break
        if k == len(A):
            ans += 1

print(ans)
# Judge status: Wrong Answer
n,x=map(int,input().split())
a=list(map(int,input().split()))
s=[0]*(n-1)
for i in range(n-1):
    s[i]=a[i]+a[i+1]
ans=0
for i in range(n-2):
    if s[i]>x:
        t=s[i]-x
        s[i+1]-=t
        s[i]=x
        ans+=t
if s[n-2]>x:
    ans+=s[n-2]-x
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())
PY = [list(map(int, input().split())) + [i] for i in range(M)]

PY.sort(key=lambda x: (x[0], x[1]))

prev_p, i = PY[0][0], PY[0][2]
out = [None] * len(PY)
out[i] = str(prev_p).zfill(6) + str(1).zfill(6)

cnt = 1
for p, y, idx in PY[1:]:
    if p != prev_p:
        cnt = 0

    cnt += 1
    prev_p = p
    out[idx] = str(p).zfill(6) + str(cnt).zfill(6)


for x in out:
    print(x)
# Judge status: Accepted
import math
r = int(input())
print(math.pi*r*2)
# Judge status: Wrong Answer
N, K, Q = map(int, input().split())
S = [K-Q]*N

for i in range(Q):
  A = int(input())
  S[A-1] += 1

C = [str(i+1) for i, s in enumerate(S) if s > 0]

print("\n".join(C))
# Judge status: Accepted
n = int(input())
x = list(map(int,input().split()))
a = x[:]
a.sort()
kijun = a[n//2]
a1 = a[n//2]
a2 = a[n//2-1]
for i in x:
	if i < kijun:
		print(a1)
	else:
		print(a2)
# Judge status: Accepted
def solve():
    x, y = map(int, input().split())
    n = (2*y-x) / 3
    m = (2*x-y) / 3

    mod = 10**9+7

    if n < 0 or m < 0 or (x+y)% 3 != 0:
        return 0
    cmb = 1
    n = int(n)
    m = int(m)
    
    cnt = 0
    for i in range(n):
        cnt += 1
        cmb *= n+m-i
        cmb *= pow(i+1, mod-2, mod)
        cmb %= mod
    return cmb

print(solve())
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
mod=10**9+7
ans=0
for i in range(60):
  x=1<<i
  o=len([0 for j in a if j&x])
  ans+=x*o*(n-o)
  ans%=mod
print(ans)
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))

d = {}
ans = 0
for i in range(n):
    if i-A[i] in d:
        ans += d[i-A[i]]
    if A[i]+i not in d:
        d[A[i]+i] = 1
    else:
        d[A[i]+i] += 1
print(ans)
# Judge status: Accepted
N=int(input())
A=int(input())
if (N%500) <= A :
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
a,b,c,d = map(int,input().split())
 
ans = 0
 
if a >= d:
    ans = d
elif (a + b) >= d:
    ans = a
elif (a + b + c) >= d:
    ans = a - (d - (a+b))
else:
    ans = a - c
    

if ans <= 0:
    ans = 0
print(ans)
# Judge status: Wrong Answer
h, w = (int(x) for x in input().split())
if w%2 == 0:
    odd_row = w // 2
    even_row = odd_row
else:
    odd_row = w // 2 + 1
    even_row = odd_row - 1
total = (h//2)*even_row + (h-h//2)*odd_row
print(total)
# Judge status: Accepted
def solve():
    K = int(input())
    a = K // 2
    b = K - a
    print(a * b)


if __name__ == '__main__':
    solve()
# Judge status: Accepted
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
win = {"r": "p", "s": "r", "p": "s"}
point = {"r": R, "s": S, "p": P}
taka = []
ans = 0
for i in range(N):
    if i >= K:
        if win[T[i]] == taka[i - K]:
            taka.append("*")
        else:
            taka.append(win[T[i]])
            ans += point[win[T[i]]]
    else:
        taka.append(win[T[i]])
        ans += point[win[T[i]]]
print(ans)
# Judge status: Wrong Answer
N = int(input())
p = input().split()
p = [int(num) for num in p]
if p == sorted(p):
  print("Yes")
else:
  q = sorted(p)
  t = 0
  for i in range(N):
    if p[i] == q[i]:
      t += 1
  if t == 2:
    print("Yes")
  else:
    print("No")
# Judge status: Wrong Answer
s = input()
x = len(s) - 1
m = 0
n = 1
c = 0
while m <= x:
  if s[m] == 'R':
    c += 1
  m += 2
while n <= x:
  if s[n] == 'L':
    c += 1
  n += 2
if c == 0:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
s = input()
if s == "AAA":
    yn = "Yes"
elif s == "BBB":
    yn = "Yes"
else:
    yn = "No"
print(yn)
# Judge status: Wrong Answer
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort()
s=0
print(sum(l[0:3]))
# Judge status: Accepted
s = input().split()
ans = "A" + s[1][0] + "C"
print(ans)
# Judge status: Accepted
# ABC105 B

def main():
    n = int(input())
    res = 'No'

    for i in range(100 // 4):
        for j in range((100-i) // 7):
            if 4 * i + 7 * j == n:
                res = 'Yes'
                break
    
    print(res)

if __name__ == '__main__':
    main()
# Judge status: Accepted
def a(s,i):
    if i == l-1:
        if eval(s)==7:
            print(s+"=7")
            exit()
        return
    a(s+"+"+N[i+1],i+1)
    a(s+"-"+N[i+1],i+1)

N = input()
l = len(N)

a(N[0],0)
# Judge status: Wrong Answer
X,Y,A,B,C=map(int, input().split())
plist=list(map(int, input().split())) 
qlist=list(map(int, input().split())) 
rlist=list(map(int, input().split())) 
plist.sort(reverse=True)
qlist.sort(reverse=True)
rlist.sort(reverse=True)
redlist = plist[:X]
greenlist = qlist[:Y]
RandG = redlist+greenlist
RandG.sort()
for i in range(min(X,Y,C)+2):
    if i > min(X,Y,C):
        break
    if sum(RandG[:i])>sum(rlist[:i]):
        break
maxdeli = sum(RandG[i-1:]) + sum(rlist[:i-1])
print(maxdeli)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
four = 0
two = 0
for i in range(n):
    if a[i] % 4 == 0:
        four += 1
    elif a[i] % 2 == 0:
        two += 1

if 2 * four + 1 >= n:
    print("Yes")
elif 2 * four + two >= n:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N, x = map(int, input().split())
a = list(map(int, input().split()))

sorted_a = sorted(a)
cont = 0

for i in range(N):
    if x >= sorted_a[i]:
        cont += 1
        x = x - sorted_a[i]
if x != 0:
    cont = cont -1
print(cont)
# Judge status: Accepted
s = input()
n = 0
ans = 0
m = [0]*2019
m[0] = 1
for i, j in enumerate(reversed(s)):
  n = (n+int(j)*pow(10, i, 2019))%2019
  m[n] += 1
for i in m: ans += i*(i-1)//2
print(ans)
# Judge status: Accepted
def solve(string):
    import numpy
    from itertools import product
    n, m, x, *ca = map(int, string.split())
    ca = numpy.array(ca).reshape((-1, m + 1)).T
    c, a = ca[0], ca[1:]
    ans = n * 10**5 + 1
    for b in product([0, 1], repeat=n):
        b = numpy.array(b)
        if (a @ b.T).min() >= x:
            ans = min(ans, c @ b.T)
    return str(ans if ans <= n * 10**5 else -1)


if __name__ == '__main__':
    import sys
    print(solve(sys.stdin.read().strip()))
# Judge status: Accepted
N = int(input())
h = list(map(int,input().split()))
inf = float("inf")

dp = [inf]*N
dp[0] = 0 #initial situation
dp[1] = abs(h[1]-h[0])


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

print(dp[N-1])
# Judge status: Wrong Answer
x, y = map(int, input().split())

nx = x*2
i = 2
while nx*2 <= y:
    nx = nx*2
    i += 1
print(i)
# Judge status: Accepted
import sys
from collections import Counter
n = int(input())
D = list(map(int,input().split()))
if D[0] != 0 or D.count(0) != 1:
    print(0)
    sys.exit()
D = Counter(D)
L = sorted(D.items())
pk = 0
pv = 1
ans = 1
for i,j in L:
    if i == 0:
        continue
    if i != pk+1:
        print(0)
        break
    ans *= pv**j
    ans %= 998244353
    pk = i
    pv = j
else:
    print(ans)
# Judge status: Accepted
A=int(input())
print(A+A*A+A*A*A)
# Judge status: Wrong Answer
k = int(input())

x = 7
e = 10

for i in range(10000000):
    # print(x)
    if x == 0:
        print(i + 1)
        exit()
    x = (x * e + 7) % k

print("-1")
# Judge status: Wrong Answer
A = input()
B = input()
C = input()
l = [A,B,C]
i = [1,0,0]
p = 0
while i[p] != len(l[p]):
  card = l[p][i[p]] 
  if card == "a":
    i[0] += 1
    p = 0
  if card == "b":
    i[1] += 1
    p = 1
  if card == "c":
    i[2] += 1
    p = 2
print(["A","B","C"][p])
# Judge status: Accepted
n = int(input())
ai = [int(i) for i in input().split()]
bi = [int(i) for i in input().split()]

sita = 0
ue = 0

for i in range(n):
    if ai[i] >= bi[i]:
        sita += ai[i] - bi[i]
    else:
        ue += (bi[i] - ai[i]+1) // 2

#print(sum(bi),sum(ai),ue,sita)
        
if sum(bi) - sum(ai) - max(ue,sita) >= 0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
import itertools
n, m, q = map(int, input().split())
num_lists = [list(map(int, input().split())) for _ in range(q)]
A = list(range(1, m+1))
ans = 0
for a in itertools.product(A, repeat=n):
  point = 0
  for num_list in num_lists:
    if num_list[2] == a[num_list[1] - 1] - a[num_list[0] - 1]:
      point += num_list[3]
  ans = max(ans, point)
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

# 勇者iが倒せるモンスター数Ciは Ci <= min(A_i+A_i+1, B_i)
# 各々の勇者が倒せる数だけ倒す貪欲法で行く

C = [0]*N
for i in range(N):
    C[i] += min(A[i],B[i])
    C[i] += min(A[i+1],B[i]-min(A[i],B[i]))
    A[i+1] = A[i+1]-min(A[i]-B[i],0)

print(sum(C))
# Judge status: Accepted
s = list(input())
k = int(input())

for i in range(len(s)):
        if ord("z")-ord(s[i])+1<=k:
                k -= (ord("z")-ord(s[i])+1)%26
                s[i] = "a"
if k: s[-1] = chr((ord(s[-1])+k-ord("a"))%26+ord("a"))
print("".join(s))
# Judge status: Accepted
n,m=map(int,input().split())
num=m//n

def make_divisors(n):
    divisors=[]
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            divisors.append(i)
            if i!=n//i:
                divisors.append(n//i)
    return divisors
make=make_divisors(m)
make.sort()
import bisect
ans=bisect.bisect_right(make,num)
print(make[ans-1])
# Judge status: Wrong Answer
y, m, d = map(int, input().split('/'))
if m <= 4:
    print("Heisei")
else:
    print("TBT")
# Judge status: Accepted
s = int(input())
x1 = 0
a = 10**9
c = 1
y1 = 0
b = 0
d = 0
t = s//(10**9)
if s%10**9==0:
  d = s//10**9
  print(x1,y1,a,b,c,d)
  exit()
d = t+1
b = 10**9-s%(10**9)
print(x1,y1,a,b,c,d)
# Judge status: Wrong Answer
s=list(input())
res=[]
for i in s:
    if i=="b":
        res=res[:-1]
    else:
        res.append(i)
print("".join(res))
# Judge status: Accepted
a,b,c = map(int,input().split())
if(b >= a * c):
  print(c)
else:
  print(b // a)
# Judge status: Accepted
N=int(input())
flag=0
count=0
for i in range(N):
    d1,d2=map(int,input().split())
    if(d1==d2):
        count+=1
    else:
        count=0
    if(count==3):
        flag=1
        break
if(flag==1):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

a,b,c,d = inpl()
x = c-a
y = d-b
res = ''
res += 'U' * y + 'R' * x
res += 'D' * y + 'L' * x
res += 'L' + 'U' * (y+1) + 'R' * (x+1) + 'D'
res += 'R' + 'D' * (y+1) + 'L' * (x+1) + 'U'
print(res)
# Judge status: Wrong Answer
import numpy as np

n,m = map(int, input().split())
from_start = np.array([])
to_end = np.array([])

for _ in range(m):
  temp = []
  temp = list(map(int, input().split()))
  if temp[0]==1:
    from_start = np.append(from_start, temp[1])
  elif temp[1]==n:
    to_end = np.append(to_end, temp[0])

if from_start in to_end:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')
# Judge status: Wrong Answer
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]

ans = []
import itertools
for A in itertools.combinations_with_replacement(range(1, M+1), N):
    tmp = 0
    print(A)
    for a, b, c, d in abcd:
        if A[b-1] - A[a-1] == c:
            tmp += d
    ans.append(tmp)
print(max(ans))
# Judge status: Wrong Answer
n = int(input())
dp = [[0 for i in range(n)] for i in range(2)]
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))

dp[0][0] = a1[0]
for i in range(1, n):
    dp[0][i] = dp[0][i - 1] + a1[i]
dp[1][0] = a2[0]

for i in range(1, n):
    dp[1][i] = max(dp[0][i] + a2[i], dp[1][i - 1] + a2[i])

if n == 1:
    print(a1[0] + a2[0])
else:
    print(dp[1][-1])
# Judge status: Accepted
N, P = map(int, input().split())
odd = sum([int(i) % 2 for i in input().split()])
even = N-odd

if odd == 0:
    if P == 0:
        print(2**even)
    else:  # P==1
        print(0)
else:
    print(2**even * (2**odd//2))
# Judge status: Accepted
x,a,b=map(int,input().split())
if abs(a-x)>abs(b-x):
  print('B')
else:
  print('A')
# Judge status: Accepted
d=int(input())
print('Christmas Eve Eve Eve' if d<23 else ('Christmas Eve Eve' if d<24 else ('Christmas Eve' if d<25 else 'Christmas')))
# Judge status: Accepted
def ncr(n,r,z):
  x=1
  y=1
  for i in range(min(r,n-r)):
    x=(x*(n-i))%z
    y=(y*(i+1))%z
  y=pow(y,z-2,z)
  return x*y%z

n,a,b=map(int,input().split())
mod=10**9+7
A=ncr(n,a,mod)
B=ncr(n,b,mod)
ans=pow(2,n,mod)-1-A-B
while ans<0:
  ans+=mod
print(ans)
# Judge status: Accepted
from sys import stdin
from sys import setrecursionlimit
from collections import Counter
setrecursionlimit(10 ** 7)

n = int(input())
a = list(map(int,stdin.readline().rstrip().split()))
su = sum(a)

q = int(input())
cc = Counter(a)

for _ in range(q):
    b,c = map(int,input().split())
    cc[c] += cc[b]
    su += c*cc[b]-b*cc[b]
    cc[b] -= cc[b]
    print(su)
# Judge status: Accepted
S=input()
N=len(S)
if S=="keyence":
    print("YES")
    exit()
for i in range(N):
    for j in range(i,N):
        tmp=""
        for k in range(N):
            if i<=k and k<=j:
                continue
            tmp=tmp+S[k]
        if tmp=="keyence":
            print("YES")
            exit()

print("NO")
# Judge status: Accepted
n = int(input())
if n % 2 == 1:
    print("No")
    exit()
s = input()
if n % 2 == 0:
    if s[n//2:] == s[:n//2]:
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
n=int(input())
a=list(map(int, input().split()))

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

stock = 0
money = 1000
for i in range(n-1):
  if delta_a[i] > 0 and (delta_a[i-1] < 0 or i == 0):
    stock = money // a[i]
    money = money % a[i]
  elif delta_a[i] < 0 and delta_a[i-1] >= 0  and stock != 0:
    money += stock * a[i]
    stock = 0

if stock != 0:
  money += stock * a[n-1]
print(money)
# Judge status: Accepted
import numpy as np
a = []
a.append([int(x) for x in input().split()])
a.append([int(x) for x in input().split()])
a.append([int(x) for x in input().split()])
n = int(input())
b = []
for i in range(n):
  b.append(int(input()))

ans = 'No'
for i in range(3):
  if set(np.array(a)[:, i]) <= set(b) or set(np.array(a)[i, :]) <= set(b):
    ans = 'Yes'

if set([a[0][0], a[1][1], a[2][2]]) <= set(b) or set([a[2][0], a[1][1], a[0][2]]) <= set(b):
  ans = 'Yes'
print(ans)
# Judge status: Accepted
N,*A=map(int,open(0).read().split());print(len([i for i in A[::2]if i%2]))
# Judge status: Accepted
x,a,b=map(int,input().split())
if abs(x-a)>abs(x-b):
  print("B")
else:
  print("A")
# Judge status: Accepted
S=input()
cnt=[0]*26
for i in S:
    cnt[ord(i)-97]+=1
for i in range(26):
    if(cnt[i]==0):
        print(chr(i+97))
        exit()
print("None")
# Judge status: Wrong Answer
N=int(input())
alp=["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"]
S=""
while N>0:
  Q=N%26
  N=N//26
  S+=alp[Q-1]
print(S[::-1])
# Judge status: Wrong Answer
#cording:utf-8

import math

N,M=map(int,input().split())

s = [int(M) for M in input().split()]
print(N,M)
print(s)

sum(s)

Pr=N-sum(s)
if Pr<= N:
    print(Pr)

else:
    print(-1)
# Judge status: Wrong Answer
Q, H, S, D = list(map(int, input().split()))
Q *= 8
H *= 4
S *= 2
A = min(Q, H, S, D)
B = min(Q, H, S) / 2
N = int(input())

print(int(N//2*A+N%2*B))
# Judge status: Wrong Answer
import copy
s=input()
check="keyence"
tmp=6
for i in reversed(s):
  if i == check[tmp]:
    tmp-=1
  else:
    break
  if tmp == -1:
    print("YES")
    exit()
    
tmp2=len(s)-(6-tmp)-1
for i in reversed(s[:tmp2+1]):
  if i != check[tmp]:
    tmp2-=1
  else:
    break
if tmp2 == 0:
  print("YES")
  exit()

tmp3=0
for i in range(tmp2,-1,-1):
  if s[i] == check[tmp]:
    tmp-=1
  else:
    print("NO")
    exit()
  if tmp == -1:
    tmp3=i
    break
if tmp3 == 0:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
N = input()

flag = False

for char in N:
  if char == '7':
    print('Yes')
    flag = True

if flag == False:   
  print('No')
# Judge status: Wrong Answer
N = int(input())
card = list(map(int,input().split()))
sorted_card = sorted(card)
Alice = 0
Bob = 0

for i in range(N):
    if i == 0 or i % 2 == 0:
        Alice += sorted_card[i]
    else:
        Bob += sorted_card[i]

print(Alice - Bob)
# Judge status: Wrong Answer
n = int(input())
ans = 0

for i in range(1, n):
    if i % 15 == 0:
        ans = ans + 0
    elif i % 3 == 0:
        ans = ans + 0
    elif i % 5 == 0:
        ans = ans + 0
    else:
        ans += i
print(ans)
# Judge status: Wrong Answer
import numpy as np
n, w = map(int, input().split())
wv = [tuple(map(int, input().split())) for _ in range(n)]

dp = np.zeros((n+1, w), np.int64)


for i in range(n):
    for sum_w in range(w):
        wi = wv[i][0]
        vi = wv[i][1]
        if sum_w - wi >= 0:
            dp[i+1][sum_w] = dp[i][sum_w - wi] + vi
        dp[i+1][sum_w] = max(dp[i][sum_w], dp[i+1][sum_w])

print(dp[n][w-1])
# Judge status: Accepted
import math
R = int(input())
p = math.pi
print(2*R*p)
# Judge status: Accepted
import sys
input = sys.stdin.readline

n = int(input())
a = [int(x) for x in input().split()]
a.sort()

ans = [-1, 0, 0]

import bisect

i = a[-1]
idx = [bisect.bisect_left(a, i / 2), bisect.bisect_left(a, i / 2) - 1]

if abs(i / 2 - a[idx[0]]) < abs(i // 2 - a[idx[1]]):
    print(i, a[idx[0]])    
else:
    print(i, a[idx[1]])
# Judge status: Accepted
def main():
    n = int(input())
    p = list(map(int, input().split(" ")))
    result = 0
    for i in range(1, n - 1):
        if p[i - 1] < p[i] < p[i + 1] or p[i + 1] < p[i] < p[i - 1]:
            result += 1
    print(result)


if __name__ == '__main__':
    main()
# Judge status: Accepted
A, B, C = map(int, input().split())
if A + B >= C:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
n,c,k = map(int,input().split())

t_tmp = 10**9+1
cnt = 0 
buses = 0 
for i in range(n):
  t = int(input())
  cnt +=1
  if t >= t_tmp+k or cnt >= c:
    buses += -(-cnt//c)
    cnt = 0
    t_tmp = t
  t_tmp = min(t_tmp,t)
#  print(i,t,t_tmp+k,cnt,buses)
buses += -(-cnt//c)
print(buses)
# Judge status: Accepted
from itertools import permutations
import math

n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]
m = math.factorial(n)
p = list(permutations(l))
d = 0

for i in range(m):
    for j in range(n-1):
        x = p[i][j][0] - p[i][j-1][0]
        y = p[i][j][1] - p[i][j-1][1]
        d += math.sqrt(x**2 + y**2)

print(d/m)
# Judge status: Accepted
import math
        
N = int(input())
T = []
for i in range(N):
    T.append(int(input()))
ans = T[0]

for i in range(1, N):
    ans = ans * T[i] // math.gcd(ans, T[i])

print(ans)
# Judge status: Accepted
n,k=map(int,input().split())
d=list(map(int,input().split()))
x=list(range(1,100001))
y=[0]*100000
for i in range(100000):
    s=str(i)
    S=len(s)
    for j in range(S):
        if int(s[j]) in d:
            y[i-1]=1
            break
for i in range(100000):
    if i>=n-1:
        if y[i]==0:
            print(i+1)
            break
# Judge status: Accepted
S = list(input())

if S[0] != "A":
    print("WA")
elif S[2:-1].count("C") != 1:
    print("WA")
else:
    S.remove("A")
    S.remove("C")
    S = "".join(S)
    if S.islower():
        print("AC")
    else:
        print("WA")
# Judge status: Accepted
n = int(input())
while True:
  if (n**0.5).is_integer():
    print(n)
    break
  else:
    n-=1
# Judge status: Wrong Answer
N=int(input())
numbers=list(map(int,input().split()))
for i in range(N):
    for k in range(i+1):
        if numbers[k]<numbers[i]:
            temp=numbers[k]
            numbers[k]=numbers[i]
            numbers[i]=temp
            break
Alice=0

Bob=0
for i in range(N//2+N%2):
    Alice+=numbers[2*i]
for i in range(N//2):
    Bob+=numbers[2*i+1]
print(Alice-Bob)
# Judge status: Wrong Answer
N = int(input())
S = list(input())
for i in range(len(S)):
  if ord(S[i])+2 <= 90:
    S[i] = chr(ord(S[i])+N)
  else:
    S[i] = chr(ord(S[i])+N-26)
for j in S:
  print(j,end = "")
# Judge status: Accepted
N = int(input())

print(N*800-(N//15)*200)
# Judge status: Wrong Answer
from fractions import gcd
n = int(input())
l = list(int(input()) for _ in range(n))

def lcm_base(x,y):
  return x*y/gcd(x,y)

ans =1
for i in l:
  ans = lcm_base(ans,i)
print(int(ans))
# Judge status: Accepted
n,k = map(int,input().split())
s = input()

cnt = 0
for i in range(len(s)):
	if s[i] == 'L':
		if i == 0:
			continue
		if s[i-1] == 'L' :
			cnt += 1
	else:
		if i == len(s) - 1:
			continue
		if s[i+1] == 'R' :
			cnt += 1

print(min(n-1,cnt + k*2))
# Judge status: Wrong Answer
import math
N, H = map(int, input().split())
max_swing = 0
throw = []
for _ in range(N):
    a, b = map(int, input().split())
    max_swing = max(max_swing, a)
    throw.append(b)

throw.sort(reverse=True)

min_cnt = int(math.ceil(H / max_swing))
throw_cnt = 0
for t in throw:
    H -= t
    throw_cnt += 1
    cnt = throw_cnt + int(math.ceil(H / max_swing))
    if H <= 0:
        min_cnt = min(throw_cnt, cnt)
        break
    min_cnt = min(cnt, min_cnt)

print(min_cnt)