peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N, x = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
while len(a) != 0:
    next = min(a)
    a.remove(min(a))
    if x < next:
        break
    x -= next
    cnt += 1

cnt = 1 if cnt == 0 else cnt
print(cnt if x == 0 else cnt-1)
# Judge status: Accepted
n = int(input())
if n<3*5*7:
    ans=0
elif n<3**3*5:
    ans=1
elif n<3*5*11:
    ans=2
elif n<3**3*7:
    ans=3
elif n<3*5*13:
    ans=4
else:
    ans=5
print(ans)
# Judge status: Accepted
N,Q = map(int,input().split())
S = input()
LR = []
for _ in range(Q):
  LR.append([int(i) for i in input().split()])

AC_point = []
for n in range(N-1):
  if S[n] == "A" and S[n+1] == "C":
    AC_point.append(n+1)
import bisect
for lr in LR:
  a = bisect.bisect_left(AC_point,lr[0])
  b = bisect.bisect_left(AC_point,lr[1])
  print(b-a)
# Judge status: Accepted
import sys

n = [int(x) for x in sys.stdin]

button = 1

for i in range(n[0]):
    if button == 2:
        print(i)
        break
    button = n[button]
else:
    print(-1)
# Judge status: Wrong Answer
n = int(input())

for i in range(1,10):
  for j in range(1,10):
    if n == i * j:
      print("Yes")
    else:
      print("No")
# Judge status: Accepted
N=int(input())

if N%1000>0:
  print(1000-N%1000)
else:
  print(0)
# Judge status: Wrong Answer
s = set(input())
t = set(input())
if len(s) != len(t):
    print('No')
else:
    if len(s&t)==0:
        print('No')
    else:
        print('Yes')
# Judge status: Wrong Answer
X, Y = map(int, input().split())
from math import log2

print(int(log2(Y//X))+1)
# Judge status: Accepted
N=int(input())
A=list(map(int, input().split()))
B=[]
for i in range (N):
    if A[i]%2==0:
        B.append(A[i])
count=0
for j in range(len(B)):
    if B[j]%3==0 or B[j]%5==0:
        count=count+1

if count==len(B):
    print("APPROVED")
else:
    print("DENIED")
# Judge status: Wrong Answer
X = int(input())
count = 0
money = 100

while True:
  money *= 1.01
  count += 1
  if money >= X:
    print(count)
    break
# Judge status: Wrong Answer
n,k = map(int, input().split())
ps = list(map(int, input().split()))

tmp = sum(ps[:k])
max_ps = tmp
start = 0

for i in range(1,n-k):
    tmp = tmp-ps[i-1]+ps[i+k-1]
    if tmp >= max_ps:
        max_ps = tmp
        start = i

print(sum([(i*(i+1))/ (2*i) for i in ps[start:start+k]]))
# Judge status: Wrong Answer
N = int(input())
List = list(map(int, input().split()))
s = 0
t = 0

for i in range(100):
  for j in range(N):
    t += (List[j]-i-1)**2

  if s>t:
    s = t

print(t)
# Judge status: Accepted
def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0
    MOD = 10 ** 9 + 7
    for d in range(60):
        one = 0
        zero = 0
        for i in range(N):
            if A[i] & (1 << d):
                one += 1
            else:
                zero += 1

        ans += (2 ** d) * (one * zero)
        ans %= MOD

    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
w,h,n = map(int, input().split())
xya = [list(map(int, input().split())) for _ in range(n)]
X = [0,w]
Y = [0,h]
for x,y,a in xya:
    if a == 1:
        X[0] = max(X[0], x)
    elif a == 2:
        X[1] = min(X[1], x)
    elif a == 3:
        Y[0] = max(Y[0], y)
    else:
        Y[1] = min(Y[1], y)
if X[0] >= X[1] or Y[0] >= Y[1]: print(0)
else: print(abs(X[0]-X[1])*abs(Y[0]-Y[1]))
# Judge status: Wrong Answer
N = int(input())
li = []
for i in range(2,100):
    for j in range(2,5):
        li.append(i**j)
li.sort()
ans = 0
for k in range(len(li)):
    if (li[k-1]<N)&(li[k]>N):
        ans = li[k-1]
print(ans)
# Judge status: Accepted
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
if N - sum(A) >= 0:
     print(N - sum(A))
else:
    print(-1)
# Judge status: Wrong Answer
s = list(input())
t = list(input())

s.sort()
t.sort(reverse=True)

flg = False
for i in range(len(s)):
    if i >= len(t):
        break
    if ord(s[i]) > ord(t[i]):
        break
    if ord(s[i]) < ord(t[i]):
        flg = True
        break
    if i == len(s)-1:
        flg = True
        break
        
print('Yes') if flg else print('No')
# Judge status: Wrong Answer
#!/usr/bin/env python3
import collections
import itertools as it
import math
import numpy as np

# A = input()
A = int(input())
# A = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()


print(A//3 * A//3 * (A-(A//3)*2))
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline

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

print(N*(N-1) + M*(M-1))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B = []
C = []
for i in range(Q):
  temp = list(map(int, input().split()))
  B.append(temp[0])
  C.append(temp[1])

d = {}
for i in range(N):
  if(A[i] not in d):
    d[A[i]] = 1
  else:
    d[A[i]] += 1
total = sum(A)
for i in range(Q):
  if(B[i] in d):
    num = d[B[i]]
    total += num*(C[i]-B[i])
    d.pop(B[i])
    if(C[i] in d):
      d[C[i]] += num
    else:
      d[C[i]] = num
  print(total)
# Judge status: Accepted
n, a, b = map(int, input().split())
mod = pow(10, 9) + 7
 
def comb(N, x):
    X = 1
    for i in range(N-x+1, N+1):
        X = X * i % mod
    Y = 1
    for j in range(1, x+1):
        Y = Y * j % mod
    Ym = pow(Y, mod-2, mod)
    return X * Ym

a = comb(n, a)
b = comb(n, b)
 
print((pow(2, n, mod) -1 -a -b) % mod)
# Judge status: Accepted
N = int(input())
Ali = list(map(int,input().split()))

Ali.sort(reverse = True)

AP = BP = 0

for i in range(N):
  if i%2 == 0:
    AP += Ali[i]
  else:
    BP += Ali[i]

print(AP-BP)
# Judge status: Accepted
n,k=map(int,input().split())
a = input()
 
a = list(a)
a[k - 1] = a[k-1].lower()
a = "".join(a)
print(a)
# Judge status: Wrong Answer
a, b, n = map(int, input().split())
ans = int((a * n) / b) - a * int(n / b)
print(max(ans, 0))
# Judge status: Accepted
N=int(input())
if N%2==0:
  print(0.5)
else:
  print((N+1)/2/N)
# Judge status: Accepted
#-*-coding:utf-8-*-

import sys

def n_gram(target, n):
    return [ target[idx:idx + n] for idx in range(len(target) - n + 1)]

def main():
    s = input()
    t = input()
    ans_list=[]
    ans=[]
    count=0

    ans_list=n_gram(s,len(t))

    for word in ans_list:
        for str1,str2 in zip(word,t):
            if str1==str2:
                count+=1
        ans.append(count)
        count=0
    print(len(t)-max(ans))

if __name__ == "__main__":
    main()
# Judge status: Accepted
N=int(input())
for a in range(1,10):
  for b in range(1,10):
    if a*b==N:
      print('Yes')
      exit()
print('No')
# Judge status: Accepted
import itertools

N, M, Q = list(map(int,input().split()))
numbers = [i for i in range(1, M+1)]
array = itertools.combinations_with_replacement(numbers, N)

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

max_score = 0
for A in array:
    score = 0
    for _ in range(Q):
        a, b, c, d = input_data[_]
        a = a - 1
        b = b - 1
        if A[b] - A[a] == c:
            score += d
    if score > max_score:
        max_score = score
    
print(max_score)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline().strip()
last_alpha = input[-1]
if last_alpha == 's':
    print(input[0:-1] + 'es')
else:
    print(input + 's')
# Judge status: Accepted
n = int(input())
for i in range(n, 1000):
    s = str(i)
    if s[0] == s[1] and s[1] == s[2]:
        print(i)
        break
# Judge status: Wrong Answer
s = list(input())

a = b = c = 0
for i in s:
    if i == "a":
        a += 1
    elif i == "b":
        b += 1
    else:
        c += 1

if a*b*c == 0 and a+b+c !=2:
    print("NO")
elif max(a,b,c)-min(a,b,c) >= 2:
    print("NO")
else:
    print("YES")
# Judge status: Accepted
import itertools
import sys

n = int(input())
S = [0]*n
while True:
    print("".join(map(lambda x:chr(ord('a')+x),S)))
    for i in range(n-1,0,-1):
        if(i>0 and max(S[:i])>=S[i]):
            S[i] += 1
            for j in range(i+1,n):
                S[j] = 0
            break
    else:
        break
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

list_over_3200 = []
list_under_3200 = []
for num in a:
    if num < 3200:
        list_under_3200.append(num // 400)
    else:
        # 3200以上の人を別のリストにいれる。
        list_over_3200.append(num)
maxAns = len(set(list_under_3200)) + len(list_over_3200)
if len(set(list_under_3200)) == 0:
    minAns = 1
else:
    minAns = len(set(list_under_3200))
print(minAns, maxAns)
# Judge status: Wrong Answer
s=input()
while True:
    s=s.replace(s[-1],'')
    if len(s)%2==0:
        if s[:len(s)//2]==s[len(s)//2:]:
          print(len(s))
          break
# Judge status: Accepted
n = int(input())

a = "abcdefghijklmnopqrstuvwxyz"
s = ""

while n > 0:
    if n%26 == 0:
        s = a[n%26-1] + s
        n //= 26
        n -= 1
    else:
        s = a[n%26-1] + s
        n //= 26
    
print(s)
# Judge status: Wrong Answer
N=input()
a=[]
s=len(N)

for i in range(s-1,-1,-1):
    a.append(int(N[i]))
a.append(0)
#print(a)

p=sum(a)
t=0
f=0
c=0
for i in range(len(a)-1):
    if a[i] <= 5:
        t+=a[i]
        if a[i] == 5 and a[i+1]>=5:a[i+1]+=1
        f=0
        
    else:
        c+=10-a[i]
        a[i+1] += 1
        f=1
        
    print(t+f+c)
# Judge status: Accepted
def count(a,b):
  c = 0
  for i in set(a):
    if i in b:
      c += 1
  return c
n = int(input())
s = input()
lmax = 0
i = n-1
while i>=0:
  left = s[:i]
  right = s[i:]
  c = count(left,right)
  lmax = max(lmax,c)
  i-=1
print(lmax)
# Judge status: Accepted
x = int(input())
ans = [1]

for i in range(2, 100):
    n = 2
    while i**n <= x:
        ans.append(i**n)
        n += 1

print(max(ans))
# Judge status: Wrong Answer
N = int(input())
S = []
count_AC = 0
count_WA = 0
count_TLE = 0
count_RE = 0
for _ in range(N):
  S.append(input())
for i in S:
  if i == "AC":
    count_AC += 1  
  elif i == "WA":
    count_WA += 1    
  elif i == "TLE":
    count_TLE += 1
  elif i == "RE":
    count_RE += 1
  else:
    pass
a = "AC" + "x" + str(count_AC)
b = "WA" + "x" + str(count_WA)
c = "TLE" + "x" + str(count_TLE)
d = "RE" + "x" + str(count_RE)
print(a, b, c, d, sep="\n")
# Judge status: Accepted
from fractions import gcd

def lcm(a,b):
  return a*b//gcd(a,b)

N,M = map(int,input().split())
A = [int(i) for i in input().split()]

a = 0
b = A[0]
while b % 2 == 0:
  a += 1
  b = b//2
  
for i in range(1,N):
  if A[i] % (2**a) != 0 or A[i] % (2**(a+1)) == 0:
    print(0)
    exit()

c = A[0]
for i in range(N-1):
  c = lcm(c,A[i+1])

print((M+c//2)//c)
# Judge status: Accepted
x,y=map(int,input().split())
if (2*y-x)%3==0 and(2*x-y)%3==0 and (2*y-x)>=0 and (2*x-y)>=0:
  
      a=(2*y-x)//3
      b=(2*x-y)//3
      numerator=1
      denominator=1
      for i in range(a):
          numerator=(numerator*(a+b-i))%(10**9+7)
          denominator=(denominator*(a-i))%(10**9+7)
      print((numerator*pow(denominator,10**9+5,10**9+7))%(10**9+7))

else:
    print(0)
# Judge status: Wrong Answer
s=list(input())
from copy import copy
t=s.copy()

for i in range(len(t)):
  if len(s)%2==0 and s[:len(s)%2]==s[len(s)%2:]:
    print(len(s)%2)
    exit()
  else:
    s.pop(-1)
# Judge status: Accepted
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

from math import ceil

n, c, k = na()
T = nin(n)
T.sort()

ans = 0
i = 0
while i < n:
    m = T[i] + k
    cnt = 0
    while i < n and T[i] <= m and cnt < c:
        i += 1
        cnt += 1
    ans += 1
print(ans)
# Judge status: Wrong Answer
n,q = map(int,input().split())
S = input()
a = [0 for i in range(n)]
count = 0
for i in range(1,n):
    if S[i] == 'C' and S[i-1] == 'A':
        count += 1
    a[i] = count
for i in range(q):
    l,r = map(int,input().split())
    print(a[r-1]-a[l-1])
print(a)
# Judge status: Wrong Answer
N = int(input())
A = int(input())

B = N - N//500
if B <= A:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
A,B,C=list(map(int,input().split()))
K=int(input())


for i in range(K):
    if A>=B:
        B=2*B
    elif B>=C:
        C=2*C
    else:
        print('Yes')
        break
    
if A<B and B<C:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import collections

N = int(input())
s = [input() for i in range(N)]

M = int(input())
t = [input() for j in range(M)]

S = collections.Counter(s)
T = collections.Counter(t)

S.most_common()
T.most_common()

ans = S - T

try:
    print(ans.most_common()[0][1])
except:
    print('0')
# Judge status: Accepted
n,m=map(int,input().split())
print((n*(n-1))//2 + (m*(m-1))//2)
# Judge status: Wrong Answer
n,k=map(int,input().split())
l=[]
if k<=9 :
  while True:
    a=n%k
    n//=k
    if n>=k:
      l.append(a)
    if n<k :
      l.append(n)
      break
  print(len(l))
else:
  print(len(str(n)))
# Judge status: Wrong Answer
max_len = 0
tmp = 0

S = input()
atcg = ['A', 'T', 'C', 'G']

for i in range(len(S)):
    if S[i] in atcg:
        tmp += 1
    else:
        max_len = max(max_len, tmp)
        tmp = 0

print(max_len)
# Judge status: Accepted
import math

N,D = map(int,input().split())
print(math.ceil(N/(2*D+1)))
# Judge status: Accepted
N = int(input())

C = input()

r = C.count('R')
w = C.count('W')

if len(C) == r or len(C) == w or C[:r].count('R') == r:
    print(0)
else:
    print(C[:r].count('W'))
# Judge status: Accepted
L,R,d=input().split()
L,R,d=int(L),int(R),int(d)
cnt=0
for i in range(L,R+1):
  if i%d==0: cnt+=1
print(cnt)
# Judge status: Accepted
N = int(input())

for i in range(1, 10**6):
    if i**2 > N:
        print((i-1)**2)
        exit()
# Judge status: Wrong Answer
N, M = map(int, input().split())
d = {}
for i in range(N):
    a, b = map(int, input().split())
    d[a] = b

d = sorted(d.items(), key=lambda x:x[0])
sum_ = 0
cnt = 0
for ab in d:
    if cnt + ab[1] > M:
        sum_ += ab[0] * (M-cnt)
        break
    else:
        cnt += ab[1]
        sum_ += ab[0]*ab[1]
print(sum_)
# Judge status: Accepted
a,b,c = map(int,input().split())
if (b-a == c-b):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
W,H,x,y=map(int,input().split())
print(W*H/2,1 if x==W/2 and y==H/2 else 0)
# Judge status: Wrong Answer
#C
N, K = map(int, input().split())
A = list(map(int, input().split()))
p=[]
import numpy as np
for i in range(N-K+1):
    ans=np.prod(A[i:i+K])
    p.append(ans)

for j in range(len(p)-1):
    if p[j]<p[j+1]:
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
x, y = map(int, input().split())
mod = 10**9+7

if (2*y-x < 0) or (2*x-y < 0):
    print(0)
    exit()

if (2*y-x)%3 != 0 or (2*x-y)%3 != 0:
    print(0)
    exit()

xc = (2*y-x)//3
yc = (2*x-y)//3
p = 1
k = 1
for i in range(1, xc+1):
    p *= (yc+i)
    k *= i
    p %= mod
    k %= mod

ans = p*pow(k, mod-2, mod)%mod
print(ans)
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
c = Counter(list(map(int, input().split())))
if len(c) == n:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
A, B, C = list(map(int, input().split()))
if A == B == C and A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    print(-1)
    exit()
ans = 0
while True:
    if A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
        ans += 1
        A, B, C = (B + C) // 2, (A + C) // 2, (A + B) // 2
    else:
        break
print(ans)
# Judge status: Wrong Answer
x="AtCoder"+input()+"Contest"
print(x)

print("A"+x[8]+"C")
# Judge status: Wrong Answer
s=int(input())

def collatz(n):
    if n%2==0:
        n=n/2
    else: 
        n=3*n+1
    return int(n)

l=[s]
while s!=1:
    s=collatz(s)
    l.append(s)

if s==1:
    print(4)
elif s==2:
    print(4)
else:
    print(len(l)+1)
# Judge status: Wrong Answer
n=int(input())
l=list(map(int,input().split(" ")))
c=0
for i in range(n):
  for j in range(i+1,n):
    if l[j]>n-1-j:
      continue
    if l[i]+l[j]==j-i:
      c+=1
      
print(c)
# Judge status: Wrong Answer
import sys
A,B,C = map(int,input().split())
ln = 100//A+1
for i in range(1,ln+1):
    if (A*i+C)% B == 0:
        print('YES')
        sys.exit()
print('NO')
# Judge status: Accepted
def readinput():
    n,k=map(int,input().split())
    s=input()
    return n,k,s

def main(n,k,s):
    ans=s[:k-1]+s[k-1].lower()+s[k:]
    return ans

if __name__=='__main__':
    n,k,s=readinput()
    ans=main(n,k,s)
    print(ans)
# Judge status: Accepted

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

if n % (2*d+1) == 0:
    print(int(n/(2*d+1)))
else:
    print(int(n/(2*d+1))+1)
# Judge status: Wrong Answer
def main():
    a, b = map(int, input().split())
    ans = (b-a)//100
    if int(str(a)[-2:]) <= int(str(a)[:2]) and int(str(b)[:2]) <= int(str(b)[-2:]):
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
ABC = list(map(int, input().split()))
K = int(input())

ABC[ABC.index(max(ABC))] *= 2 * K
print(sum(ABC))
# Judge status: Wrong Answer
import itertools

aList = []

for i in range(5):
  aList.append(int(input()))

k = int(input())

aiList = list(itertools.combinations(aList,2))

for j in aiList:
  if j[1] - j[0] >k:  
    print(":(")
    exit(0)

print("Yay")
# Judge status: Wrong Answer
import math
ina=input().split()
i=int(ina[0]+ina[1])
if math.sqrt(i)**2 == i:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
X = map(int, input().split())

for i in X:
    if X == 0:
        print(i + 1)
# Judge status: Wrong Answer
N = int(input())
S = str(input())

WtoE=0
EtoW=S[1:N+1].count('E')
min_ans = WtoE + EtoW

for i in range(1, N+1):
    print(i)
    if S[i-1] == 'W':
        WtoE += 1
    if S[i-1] == 'E':
        EtoW -= 1
    ans = WtoE + EtoW

    if min_ans > ans:
        min_ans = ans

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

a = []
for i in range(n):
  arr = list(map(int, input().split()))
  a.append(arr)

INF = -10 ** 18

dp = [ [INF] * 3 for i in range(0, n+1)]
dp[0] = [0] * 3

for i in range(0, n):
  for j in range(0, 3):
    for k in range(3):
      if (j == k): continue
      dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k])

print(max(dp[-1]))
# Judge status: Accepted
n = int(input())
l = list(map(int, input().split()))
ans = 0
for i in range(0, n):
    for j in range(i+1, n):
        for k in range(j+1, n):
            if l[i] == l[j] or l[i] == l[k] or l[j] == l[k]:
                continue
            if l[i]+l[j] > l[k] and l[k]+l[j] > l[i] and l[k]+l[i] > l[j]:
                ans += 1

print(ans)
# Judge status: Accepted

n = int(input())
h = list(map(int, input().split()))

dp = [float('inf')]*n
dp[0] = 0
for i in range(n):
    if i+1 < n:
        dp[i+1] = min(dp[i+1], abs(h[i] - h[i+1]) + dp[i]) 
    if i+2 < n:
        dp[i+2] = min(dp[i+2], abs(h[i] - h[i+2]) + dp[i])
print(dp[-1])
# Judge status: Wrong Answer
import math
n = int(input())
a = list(map(int, input().split()))
mod = 10**9 + 7

def lcm(a, b):
    return (a * b) // math.gcd(a, b)

a_gcd = 1
a_seki = 1
for i in range(n):
    a_gcd = math.gcd(a_gcd, a[i])
    a_seki = a_seki * a[i]
a_lcm = a_seki//a_gcd

b_sum = 0
for i in range(n):
    b_sum = (b_sum + (a_lcm // a[i])) % mod

print(b_sum)
# Judge status: Accepted
import math

print(2 ** int(math.log2(int(input()))))
# Judge status: Accepted
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()
count = {"r": 0, "s": 0, "p": 0}
win = [-1 for i in range(N)]

for i in range(N):
    if i < K:
        count[T[i]] += 1
        win[i] = 1
    else:
        if T[i] == T[i-K] and win[i-K] == 1:
            win[i] = 0
        else:
            count[T[i]] += 1
            win[i] = 1

score = R*count["s"] + S*count["p"] + P*count["r"]
print(score)
# Judge status: Accepted
from collections import Counter
n, k = map(int, input().split())
a = list(map(int, input().split()))
print(sum(sorted(Counter(a).values())[0:len(set(a)) - k]))
# Judge status: Accepted
class Work:
    require = 0
    limit = 0
    def __init__(self, require, limit) -> None:
        self.require = require
        self.limit = limit

def from_list(xs) -> Work: 
    return Work(xs[0], xs[1])

N = int(input())

works = [from_list([int(_) for _ in input().split()]) for i in range(N)]

def solve(works):
    works.sort(key=lambda x: x.limit)
    acc = 0
    for w in works:
        acc += w.require
        if acc > w.limit:
            return "No"
    return "Yes"

print(solve(works))
# Judge status: Accepted
S, W = map(int, input().split())

if S>W:
    print('safe')
else:
    print('unsafe')
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
print("Yes" if a+b>=c else "NO")
# Judge status: Accepted
def main():
    N, A, B = map(int, input().split())

    if abs(A-B) % 2 == 0:
        print(abs(A-B)//2)
    else:
        print(min([A-1, N-B])+1+(B-A-1)//2)


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

ans = -A[0]
for i in range(N):
    ans += A[i//2]
print(ans)
# Judge status: Wrong Answer
a,b,c,k = map(int,input().split())
if a>k:
    print(a)
elif a+b >= k:
    print(a)
else:
    print(a-(k-a-b))
# Judge status: Wrong Answer
s = input()

flag = True
n = len(s)
for i in range(n//4):
  if s[i] == s[(n-1)//2 -1 - i] == s[(n+3)//2 -1 + i] == s[n-1 - i]:
    break
  else:
    flag = False

if flag == True:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n, m = map(int, input().split())
a = set(map(int, [input() for _ in range(m)]))

dp = [0] * (n+1)
# 0段目と1段目は1通り（但し、１段目が壊れていない場合）（0 段目は「なにもしない」という から1 通り）
dp[:2] = 1, 1 if 1 not in a else 0 

for i in range(2, n+1):
    if i not in a:
        dp[i] = ((dp[i-1] + dp[i-2]) % (10**9+7))

print(dp[-1])
# Judge status: Wrong Answer
import math

n, d = map(int, input().split())
x = [list(map(int, input().split())) for i in range(n)]
cnt = 0
for i in range(n):
    for j in range(i+1, n):
        for k in range(d):
            dis = 0
            dis += (x[i][k]-x[j][k])**2
            if math.sqrt(dis) % 1 == 0:
                cnt += 1
print(cnt)
# Judge status: Accepted
from sys import stdin
import sys

K=int(input())
S=input()
if len(S)<=K:
    print(S)
else:
    print(S[:K]+'...')
# Judge status: Wrong Answer
n,m=[int(x) for x in input().rstrip().split()]
A=[int(x) for x in input().rstrip().split()]
now=[]
bc=[]
for i in range(m):
  BC=[int(x) for x in input().rstrip().split()]
  bc.append(BC)
bc=sorted(bc,key=lambda x:x[1])
A.sort(reverse=True)
d=[]
for b,c in bc:
    d.extend([c]*b)
    if n<=len(d):
      break
A+=d
A.sort(reverse=True)
print(sum(A[:n]))
# Judge status: Accepted
a,b = map(int,input().split())

if a == b:
    print('Draw')
elif a < b:
    if a == 1:
        print('Alice')
    else:
        print('Bob')
else:
    if b == 1:
        print('Bob')
    else:
        print('Alice')
# Judge status: Accepted
a,b,c,k=map(int,input().split())
if(k<=a):
  print(k)
else:
  print(a-(k-a-b))
# Judge status: Wrong Answer
def mapint_inp():
    return map(int, input().split())

A, B, C = mapint_inp()

print(-1)
# Judge status: Accepted
n = int(input())
h = []
tmp = ["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"]
name = ""

while n != 0:
    mod = n % 26
    h.append(mod)
    n //= 26
    if mod == 0:
        n -= 1
h.reverse()
for i in h:
    name += tmp[i - 1]
print(name)
# Judge status: Accepted
O = list(input())
lo = len(O)
E = list(input())
le = len(E)
w = lo + le

X = ['*']*w
for i in range(le):
  X[2*i] =O[i]
  X[2*i+1] = E[i]
if lo > le:
  X[-1] = O[-1]
  
print(''.join(X))
# Judge status: Wrong Answer
def main():
  N=int(input())
  a=list(map(int,input().split()))
  p=max(a)
  m=len(bin(p))-2
  for i in range(N):
    b=len(bin(a[i]))-2
    ans=0
    for j in range(b):
      if a[i]>>j&1==1:
        if j==m-1 or j==0:
          ans+=pow(2,j)
      else:
        if j==m-1 or j==0:
          continue
        ans+=pow(2,j)
    print(ans,end=' ')
if __name__=='__main__':
  main()