Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import numpy as np
import math
"""
def search(min_,max_,A,B,arr):
#    print(min_,max_)
    if min_==max_:
        return min_
    mid=(max_+min_)//2
    
    tmp=arr-mid*B
    
    if len(tmp)==0:
        return search(min_,mid,A,B,arr)
    
    tmp=map(lambda x:math.ceil(x/(A-B)),tmp)
    sum_=sum(list(tmp))
    if sum_<=mid:
        return search(min_,mid,A,B,arr)
    else:
        return search(mid+1,max_,A,B,arr)

    while True:
        if k<0:
            if mid==min_:
                return max_
            else:
                #failure
                return search(mid,max_,A,B,arr[:L])
        elif len(tmp)==0:
            #success
            return search(min_,mid,A,B,arr)
        x=-tmp[0]
        tmp=np.delete(tmp,0)
        k-=x//(A-B)+(x%(A-B)>0)
"""
        
    
N,A,B=list(map(int,input().split()))
arr=[]

for i in range(N):
    h=int(input())
    arr.append(h)
arr=np.array(arr)

max_=max(arr)//B+1
min_=min(arr)//A

d=A-B

while min_!=max_:
    mid=(max_+min_)//2
    
    tmp=arr-mid*B
    
    sum_=0
    for x in tmp:
        sum_+=math.ceil(x/d)
    
    if sum_<=mid:
        max_=mid
    else:
        min_=mid+1

print(min_)

### FIXED CODE ###

import math
"""
def search(min_,max_,A,B,arr):
#    print(min_,max_)
    if min_==max_:
        return min_
    mid=(max_+min_)//2
    
    tmp=arr-mid*B
    
    if len(tmp)==0:
        return search(min_,mid,A,B,arr)
    
    tmp=map(lambda x:math.ceil(x/(A-B)),tmp)
    sum_=sum(list(tmp))
    if sum_<=mid:
        return search(min_,mid,A,B,arr)
    else:
        return search(mid+1,max_,A,B,arr)

    while True:
        if k<0:
            if mid==min_:
                return max_
            else:
                #failure
                return search(mid,max_,A,B,arr[:L])
        elif len(tmp)==0:
            #success
            return search(min_,mid,A,B,arr)
        x=-tmp[0]
        tmp=np.delete(tmp,0)
        k-=x//(A-B)+(x%(A-B)>0)
"""
        
    
N,A,B=list(map(int,input().split()))
arr=[]

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

max_=max(arr)//B+1
min_=min(arr)//A

d=A-B

while min_!=max_:
    mid=(max_+min_)//2
    
    sum_=0
    for x in arr:
        sum_+=max(0,math.ceil((x-mid*B)/d))
        
    if sum_<=mid:
        max_=mid
    else:
        min_=mid+1

print(min_)
### BUGGY CODE ###

x = int(input())

i = 1
a = 1
b = 0
while a**5 - b**5 <= x:
    if a**5 - b**5 == x:
        print(a, b)
        exit()
    a += 1
    b -= 1

while True:
    i += 1
    if x % i:
        continue

    b = 1
    a = i - b
    while b < a and a**5 - b**5 <= x:
        if a**5 - b**5 == x:
            print(a, b)
            exit()
        a += 1
        b -= 1

    a = i
    b = 0
    while a**5 - b**5 <= x:
        if a**5 - b**5 == x:
            print(a, b)
            exit()
        a += 1
        b -= 1

### FIXED CODE ###

x = int(input())
OP = [+1, -1]
for a in range(1000):
    for b in range(a + 1):
        for op1 in OP:
            for op2 in OP:
                if (op1 * a)**5 - (op2 * b)**5 == x:
                    print(op1 * a, op2 * b)
                    exit()
### BUGGY CODE ###

import numpy as np


T = int(input())
for i in range(T):
    n = int(input())
    A = list(map(int, input().split()))
    S = [int(x) for x in input()]
    dp = np.array([0])
    for j in reversed(range(n)):
        if S[j] == 0:
            dp = np.unique(np.append(dp, dp ^ A[j]))
        elif not A[j] in dp:
            print(1)
            break
    else:
        print(0)


### FIXED CODE ###

T = int(input())
for i in range(T):
    n = int(input())
    A = list(map(int, input().split()))
    S = input()
    dp = []
    for j in reversed(range(n)):
        a = A[j]
        for x in dp:
            a = min(a, a^x)
        if a > 0:
            if S[j] == '0':
                dp.append(a)
            elif not A[j] in dp:
                print(1)
                break
    else:
        print(0)
### BUGGY CODE ###

# Problem D - Double Dots

# input
N, M = map(int, input().split())
graph_list = {}
for i in range(M):
    a, b = map(int, input().split())
    if a in graph_list:
        graph_list[a].append(b)
    else:
        graph_list[a] = [b]

    if b in graph_list:
        graph_list[b].append(a)
    else:
        graph_list[b] = [a]

# initialization
visit_list = [0]*N
distance_list = [float("INF")]*N
distance_list[0] = 0
visit_queue = [1]
queue_count = 1

# bfs search
while queue_count>0:
    v = visit_queue.pop()
    queue_count -= 1

    graph = graph_list[v]
    for n in graph:
        if distance_list[v-1]+1<distance_list[n-1]:
            distance_list[n-1] = distance_list[v-1] + 1
            visit_list[n-1] = v
            visit_queue.append(n)
            queue_count += 1

# output
print("Yes")
for i in range(1, N):
    print(visit_list[i])


### FIXED CODE ###

# Problem D - Double Dots

from collections import deque

# input
N, M = map(int, input().split())
graph_list = {}
for i in range(M):
    a, b = map(int, input().split())
    if a in graph_list:
        graph_list[a].append(b)
    else:
        graph_list[a] = [b]

    if b in graph_list:
        graph_list[b].append(a)
    else:
        graph_list[b] = [a]

# initialization
visit_list = [0]*N
distance_list = [float("INF")]*N
distance_list[0] = 0
visit_queue = deque([1])
queue_count = 1

# bfs search
while queue_count>0:
    v = visit_queue.popleft()
    queue_count -= 1

    graph = graph_list[v]
    for n in graph:
        if distance_list[v-1]+1<distance_list[n-1]:
            distance_list[n-1] = distance_list[v-1] + 1
            visit_list[n-1] = v
            visit_queue.append(n)
            queue_count += 1

# output
print("Yes")
for i in range(1, N):
    print(visit_list[i])
### BUGGY CODE ###

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

card_list = [1 for _ in range(a)] + [0 for _ in range(b)] + [-1 for _ in range(c)] 

print(sum(card_list[:k]))

### FIXED CODE ###

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

if a >= k:
    print(k)
elif a + b >= k:
    print(a)
else:
    print(a - (k - (a + b)))
### BUGGY CODE ###

p = int(input())
a = list(map(int, input().split()))

list_size = p-1

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % p)

f_r_list[-1] = pow(f_list[-1], p - 2, p)

for i in range(2, list_size + 1):
	f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % p)

def comb(n, r):
	if n < r:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (((f_list[n - 1] * f_r_list[n - r - 1]) % p) * f_r_list[r - 1]) % p 

ans = [0 for _ in range(p)]
for i, x in enumerate(a):
	if x == 1:
		ans[0] += 1
		ans[0] %= p
		for j in range(p):
			ans[j] -= pow(p-i, p-1-j, p) * comb(p-1, j)
			ans[j] %= p

print(*ans)

### FIXED CODE ###

p = int(input())
a = list(map(int, input().split()))

list_size = p-1

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size - 1):
	f_list[i + 1] = int((f_list[i] * (i + 2)) % p)

f_r_list[-1] = pow(f_list[-1], p - 2, p)

for i in range(2, list_size + 1):
	f_r_list[-i] = int((f_r_list[-i + 1] * (list_size + 2 - i)) % p)

def comb(n, r):
	if n < r:
		return 0
	elif n == 0 or r == 0 or n == r:
		return 1
	else:
		return (((f_list[n - 1] * f_r_list[n - r - 1]) % p) * f_r_list[r - 1]) % p 

pows = [[1] for x in range(p)]
for i in range(p):
	for _ in range(p-1):
		pows[i].append((pows[i][-1] * i) % p)

ans = [0 for _ in range(p)]
for i, x in enumerate(a):
	if x == 0:
		continue
	ans[0] += 1
	ans[0] %= p
	for j in range(p):
		ans[j] -= pows[(p-i)%p][p-1-j] * comb(p-1, j)
		ans[j] %= p

print(*ans)
### BUGGY CODE ###


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

C = [float('inf')] * (1 << N)
C[0] = 0

for j in range(M):
    a, b = map(int, input().split())
    box = list(map(int, input().split()))
    for i in range(1 << N):
        now_status = i
        score = C[now_status] + a
        if score == float("inf"):
            continue

        ex_status = 0
        for j in box:
            ex_status += 1 << (j-1)
        now_status = i | ex_status

        if C[now_status] > score:
            C[now_status] = score

if C[-1] == float("inf"):
    print(-1)
else:
    print(C[-1])



### FIXED CODE ###


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

C = [float('inf')] * (1 << N)
C[0] = 0
key_v = [float('inf')] * (1 << N)
for j in range(M):
    a, b = map(int, input().split())
    box = list(map(int, input().split()))
    ex_status = 0
    for j in box:
        ex_status += 1 << (j-1)
    key_v[ex_status] = min(a, key_v[ex_status])

for key, val in enumerate(key_v):
    if val == float('inf'):
        continue
    for i in range(1 << N):
        now_status = i
        score = C[now_status] + val
        if score == float("inf"):
            continue

        now_status = i | key

        if C[now_status] > score:
            C[now_status] = score

if C[-1] == float("inf"):
    print(-1)
else:
    print(C[-1])
### BUGGY CODE ###

t=input()
s=list(map(int,input().split()))
a=int(t)
b=0
c=0
d=0
for i in range(a-1):
  b+=1
  c=0
  for j in range(b,a):
    if s[i]>=s[j]:
      c += 1
      i += 1
      d=max(d,c)
    else: 
      break
print(d)

### FIXED CODE ###

t=input()
s=list(map(int,input().split()))
a=int(t)
list=[]
for i in range(a-1):
  if s[i]>=s[i+1]:
    list.append(1)
  else:
    list.append(0)
d=0
c=0
for i in range(a-1):
  if list[i]==1:
    c+=1
    d=max(d,c)
  else:
    c=0
print(d)
### BUGGY CODE ###

N = int(input())
li = list(map(int,input().split()))
 
for i in range(1,N+1):
  print(li.count(i))

### FIXED CODE ###

import collections

N = int(input())
li = list(map(int,input().split()))
clist = collections.Counter(li)
for i in range(1,N+1):
  print(clist[i])
### BUGGY CODE ###

from collections import defaultdict
n,m=map(int,input().split())
d = defaultdict(int)
for i in range(m):
  s, e = map(int,input().split())
  for j in range(s,e+1):
    j = str(j)
    d[j] += 1
#print(d)
count = 0
for k,v in d.items():
  if v==m:
    count+=1
print(count)

### FIXED CODE ###

n,m=map(int,input().split())
mi = 0
ma = 10**5+1
for i in range(m):
  s,e = map(int,input().split())
  if s > mi:
    mi = s
#    print('mi',mi)
  if e < ma:
    ma = e
#    print('ma',ma)
print(max(ma-mi+1,0))
### BUGGY CODE ###

#!/usr/bin/env python3
# -*- coding: utf-8 -*-


H, W, D = map(int, input().split())

MAP  = {}
COST = {}

for i in range(H):
    for j, l in enumerate(list(map(int, input().split()))):
        MAP[l] = (i, j)


Q = int(input())

for i in range(Q):
    L, R = map(int, input().split())
    cost = 0
    while L != R:
        if '%s,%s' % (L, L+D) in COST.keys():
            pass
        else:
            COST['%s,%s' % (L, L+D)] = abs(MAP[L][0] - MAP[L+D][0]) + abs(MAP[L][1] - MAP[L+D][1])
        cost += COST['%s,%s' % (L, L+D)]
        L    += D
    print(cost, flush=True)


### FIXED CODE ###

# speed-test
# https://abc089.contest.atcoder.jp/submissions/2206669

h,w,d = map(int,input().split())
 
dic = {}
for i in range(h):
    a = input().split()
    for j in range(w):
        dic[int(a[j])] = (i+1,j+1)
        
q = int(input())
c = [0]*(h*w+1)
for i in range(d+1,h*w+1):
    pi,pj = dic[i]; qi,qj = dic[i-d]
    c[i] = c[i-d] + abs(pi-qi) + abs(pj-qj)
    
for i in range(q):
    l,r = map(int,input().split())
    print(c[r]-c[l])
### BUGGY CODE ###

from array import array
from itertools import islice, repeat


def main():
    city_count, express_count, query_count = map(int, input().split())

    city_list = [array('L', repeat(0, city_count + 1))
                 for _ in range(city_count + 1)]

    for express_index in range(1, express_count + 1):
        l, r = map(int, input().split())
        city_list[l][r] += 1

    for _ in range(query_count):
        p, q = map(int, input().split())
        answer = 0
        for left_index, right_list in enumerate(islice(city_list, p, q + 1), p):
            answer += sum(islice(right_list, left_index, q + 1))
        print(answer)


if __name__ == '__main__':
    main()


### FIXED CODE ###

from array import array
from itertools import accumulate, repeat, starmap
from operator import add, itemgetter


def main():
    city_count, express_count, query_count = map(int, input().split())

    city_list = [array('L', repeat(0, city_count + 1))
                 for _ in range(city_count + 1)]

    for _ in range(express_count):
        l, r = map(int, input().split())
        city_list[l][r] += 1

    for city_index in range(1, city_count + 1):
        city_list[city_index] = array('L', accumulate(city_list[city_index]))

    for city_index in range(2, city_count + 1):
        city_list[city_index] = array('L', starmap(
            add, zip(*(city_list[city_index + i] for i in (-1, 0)))))

    for _ in range(query_count):
        p, q = map(int, input().split())
        print(city_list[q][q] - city_list[p - 1][q])


if __name__ == '__main__':
    main()
### BUGGY CODE ###

import copy

N, A, B, C = list(map(int, input().split()))
ls = [int(input()) for i in range(N)]

nums = [[[], [], []],
        [[], [], []],
        [[], [], []]] 
    
for l in ls:
    tmpA = []
    for num in nums:
        for i in range(3):
            tmpB = copy.deepcopy(num)
            tmpB[i].append(l)
            tmpA.append(tmpB)
    nums.extend(tmpA)   

ans = 10**20

for num in nums:
    n = abs(A-sum(num[0])) + abs(B-sum(num[1])) + abs(C-sum(num[2])) + 10*(max(0, len(num[0])-1)) + 10*(max(0, len(num[1])-1)) + 10*(max(0, len(num[2])-1))
    
    ans = min(ans, n)
print(ans)


### FIXED CODE ###

def search(idx, a, b, c):
    if idx == N:
        if min(a, b, c) > 0:
            return abs(A-a) + abs(B-b) + abs(C-c) - 30
        else:
            return 10**20
            
    n0 = search(idx+1, a, b, c)
    n1 = search(idx+1, a+l[idx], b, c) + 10
    n2 = search(idx+1, a, b+l[idx], c) + 10
    n3 = search(idx+1, a, b, c+l[idx]) + 10
    
    return min(n0, n1, n2, n3)
    
N, A, B, C = list(map(int, input().split()))
l = [int(input()) for i in range(N)]

print(search(0, 0, 0, 0))
### BUGGY CODE ###

S = input()
Q = int(input())
Flag = True

for i in range(Q):
    Query = input()
    if Query[0] == "1":
        Flag = not Flag
    else:
        QueryList = Query.split()
        if Flag:
            if QueryList[1] =="1":
                S = QueryList[2]+S
            else:
                S = S+QueryList[2]
        else:
            if QueryList[1] =="2":
                S = QueryList[2]+S
            else:
                S = S+QueryList[2]

if Flag:
    print(S)
else:
    S = S[::-1]
    print(S)

### FIXED CODE ###

from collections import deque

d = deque()
S = input()
d.append(S)
Q = int(input())
Flag = True
 
for i in range(Q):
    Query = input()
    if Query[0] == "1":
        Flag = not Flag
    else:
        QueryList = Query.split()
        if Flag:
            if QueryList[1] =="1":
                d.appendleft(QueryList[2])
            else:
                d.append(QueryList[2])
        else:
            if QueryList[1] =="2":
                d.appendleft(QueryList[2])
            else:
                d.append(QueryList[2])

d_string = "".join(list(d))

if not Flag:
    d_string = d_string[::-1]    
print(d_string)
### BUGGY CODE ###

def solve(c, a):
    dp = {c: 0}
    for w, p in a:
        dp2 = dp.copy()
        for rc, v in dp.items():
            if rc >= w:
                dp2[rc-w] = max(dp2.get(rc-w, 0), v + p)
        dp = dp2
    return max(dp.values())
  
n, k = map(int, input().split())
a = []
for _ in range(n):
    a.append(list(map(int, input().split())))
print(solve(k, a))

### FIXED CODE ###

def solve(c, a):
    dp = [float('inf')]*(2*10**5)
    dp[0] = 0
    for w, v in a:
        for i in range(len(dp)-1, -1, -1):
            if dp[i] != float('inf'):
                dp[i+v] = min(dp[i+v], dp[i] + w)
    return next(i for i in range(len(dp)-1, -1, -1) if dp[i] <= c)
  
n, k = map(int, input().split())
a = []
for _ in range(n):
    a.append(list(map(int, input().split())))
print(solve(k, a))
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def solve(S: str):

    l = [0] * 2019
    ps = 0
    d = 1
    for i in range(1, len(S) + 1):
        ps += int(S[-i]) * d
        l[ ps % 2019 ] += 1
        d *= 10

    ans = 0
    for i in l:
        ans += i * (i - 1) // 2
    
    ans += l[0]
    
    print(ans)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(S: str):

    l = [0] * 2019
    ps = 0
    d = 1
    for i in range(1, len(S) + 1):
        ps += int(S[-i]) * d
        l[ ps % 2019 ] += 1
        d = d * 10 % 2019

    ans = 0
    for i in l:
        ans += i * (i - 1) // 2
    
    ans += l[0]
    
    print(ans)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

import copy
n = int(input())
x_tmp = input().split()
x = []
for _ in x_tmp:
    x.append(int(_))
num = n//2
for i in range(n):
    tmp_x = copy.copy(x)  # listを普通に代入すると、ディープコピーになる
    tmp_x.pop(i)  # pop(index)の出力は、削除した要素の値
    # その上で、popするとリスト自体も改変される
    # print(tmp_x)
    tmp_x = sorted(tmp_x, reverse=True)
    # print(tmp_x)
    print(tmp_x[num-1])


### FIXED CODE ###

n = int(input())
x_tmp = input().split()
x = [[0 for j in range(3)] for i in range(n)]
for i in range(n):
    x[i][0] = int(x_tmp[i])
    x[i][1] = i
x = sorted(x, key=lambda y: y[0])
mid = n//2
for i in range(n):
    if i <= mid-1:
        x[i][2] = x[mid][0]
    else:
        x[i][2] = x[mid-1][0]
x = sorted(x, key=lambda y: y[1])
for i in range(n):
    print(x[i][2])
### BUGGY CODE ###

import fractions
K = int(input())
def gcd3(a,b,c):
    return fractions.gcd(fractions.gcd(a,b),c)
ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            ans += gcd3(i,j,k)
print(ans)

### FIXED CODE ###

import fractions
K = int(input())
ans = 0
dp = []
for i in range(0,K+1):
    dpp = []
    for j in range(0,K+1):
        dpp.append(0)
    dp.append(dpp)
def dpgcd(a,b):
    if dp[a][b] != 0:
        return dp[a][b]
    else:
        gg = fractions.gcd(a,b)
        dp[a][b] = gg
        dp[b][a] = gg
        return gg
for i in range(0,K):
    for j in range(0,K):
        g = dpgcd(i+1,j+1)
        for k in range(0,K):
            ans += dpgcd(g,k+1)
print(ans)
### BUGGY CODE ###

if __name__ == "__main__":
  n = int(input())
  nums = list(map(int, input().split()))
  result = 1
  if 0 in nums:
    print(0)
  else:
    for i in nums:
      result *= i
    if result > 1000000000000000000:
      print(-1)
    else:
      print(result)

### FIXED CODE ###

def main():
  n = int(input())
  nums = list(map(int, input().split()))
  result = 1
  if 0 in nums:
    print(0)
    return
  else:
    for i in nums:
      result *= i
      if result > 1000000000000000000:
        print(-1)
        return
    print(result)
    return


if __name__ == "__main__":
  main()
### BUGGY CODE ###

from heapq import heappop, heappush

n = int(input())
xd = [list(map(int, input().split())) for _ in range(n)]
mod = 998244353
INF = 10 ** 18

xx = []
for i, (x, d) in enumerate(xd, 1):
    xx.append([i, x, 0])
    xx.append([i, x + d - 0.5, 1])

xx.sort(key=lambda x: x[1])

adj = [[] for _ in range(n + 1)]
now = {0}
hp = [(INF, 0)]
for i, x, remove in xx:
    if remove:
        now.remove(i)

    else:
        now.add(i)
        while hp[0][1] not in now:
            heappop(hp)

        px, pi = hp[0]
        adj[pi].append(i)

        heappush(hp, (-x, i))

stack = [0]
d = [-1] * (n + 1)
d[0] = 0
c = [[] for _ in range(n + 1)]
order = []
while stack:
    u = stack.pop()
    order.append(u)
    for v in adj[u]:
        if d[v] == -1:
            d[v] = d[u] + 1
            c[u].append(v)
            stack.append(v)

dp = [1] * (n + 1)
for u in order[::-1]:
    for v in c[u]:
        dp[u] *= dp[v]
        dp[u] %= mod

    dp[u] += 1
    dp[u] %= mod

ans = dp[0] - 1
ans %= mod
print(ans)


### FIXED CODE ###

def main():
    n = int(input())
    xd = [map(int, input().split()) for _ in range(n)]
    mod = 998244353
    INF = 10 ** 10

    xx = [(x, x + d, i) for i, (x, d) in enumerate(xd, 1)]
    xx.sort()
    adj = [[] for _ in range(n + 1)]
    stack = [(INF, 0)]
    for l, r, i in xx:
        while stack[-1][0] <= l:
            stack.pop()

        ip = stack[-1][1]
        adj[ip].append(i)
        stack.append((r, i))

    stack2 = [0]
    d = [-1] * (n + 1)
    d[0] = 0
    c = [[] for _ in range(n + 1)]
    order = []
    while stack2:
        u = stack2.pop()
        order.append(u)
        for v in adj[u]:
            if d[v] == -1:
                d[v] = d[u] + 1
                c[u].append(v)
                stack2.append(v)

    dp = [1] * (n + 1)
    for u in order[::-1]:
        for v in c[u]:
            dp[u] *= dp[v]
            dp[u] %= mod

        dp[u] += 1
        dp[u] %= mod

    ans = dp[0] - 1
    ans %= mod
    print(ans)


if __name__ == "__main__":
    main()