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

import copy
import numpy as np
from scipy.sparse import csr_matrix

def openinput() :
    n, m = map(int, input().split())
    s ,t = [], []
    for _ in range(m):
        si, ti = map(int, input().split())
        s.append(si - 1)
        t.append(ti - 1)
    return n, m, s, t

def make_adjacency_matrix(weights, edges, num_of_nodes):
    return csr_matrix((weights, edges), shape=(num_of_nodes, num_of_nodes)).toarray()

def next_nodes(adjacency_matrix, node):
    return [v for (v, e) in enumerate(adjacency_matrix[node]) if e > 0]

def editted_mat(mat, weight, edge_from, edge_to):
    copied = copy.deepcopy(mat)
    copied[edge_from, edge_to] = weight
    return copied

def v_to_n_expected(adjacency_matrix, num_of_nodes, recursive_depth=0):
    dp_table = np.zeros(num_of_nodes)

    recursive_expected = []
    for v in range(num_of_nodes-1, 0, -1):
        nexts = next_nodes(adjacency_matrix, v-1)
        if recursive_depth < 1:
            max_next = nexts[np.argmax(dp_table[next] for next in nexts)]
            edimat = editted_mat(adjacency_matrix, 0, v-1, max_next)
            expected = v_to_n_expected(edimat, num_of_nodes, recursive_depth=1)
            recursive_expected.append(expected)
        
        num_of_nexts = len(nexts)
        if num_of_nexts > 0:
            dp_table[v-1] = 1 + sum(dp_table[next] for next in nexts) / num_of_nexts
        else:
            dp_table[v-1] = np.inf
    recursive_expected.append(dp_table[0])
    return min(recursive_expected)

if __name__ == '__main__':
    n, m, s, t = openinput()
    adjacency_matrix = make_adjacency_matrix([1]*m, (s,t), n)
    expcted_values = v_to_n_expected(adjacency_matrix, n)
    print(expcted_values)

### FIXED CODE ###

# reference: https://www.onakasuitacity.com/abc144-f/

import numpy as np

n, m = map(int, input().split())
outgoing = [[] for _ in range(n)]
incoming = [[] for _ in range(n)]
for _ in range(m):
    si, ti = map(int, input().split())
    outgoing[si-1].append(ti-1)
    incoming[ti-1].append(si-1)


ex_dp = np.zeros(n)
for v in reversed(range(n-1)):   # O(m)
    outgoing_degree = len(outgoing[v])
    ex_dp[v] = 1 + sum(ex_dp[post] for post in outgoing[v])/outgoing_degree if outgoing_degree!=0 else np.inf

p_dp = np.ones(n)
for v in range(1,n):      # O(m)
    p_dp[v] = sum(p_dp[prev]/len(outgoing[prev]) for prev in incoming[v])

min_ex = ex_dp[0]
for v, posts in enumerate(outgoing):      # O(m)
    outgoing_degree = len(outgoing[v])
    if outgoing_degree <= 1:
        continue

    max_post = max(posts, key= lambda pos: ex_dp[pos])
    diff_v_ex = 0
    for w in posts:
        if w == max_post:
            diff_v_ex -= 1/outgoing_degree * ex_dp[w]
        else:
            diff_v_ex += 1/(outgoing_degree*(outgoing_degree-1)) * ex_dp[w]
    min_ex = min(ex_dp[0] + p_dp[v] * diff_v_ex, min_ex)

print(min_ex)
### BUGGY CODE ###

n, k = list(map(int, input().split()))
p = list(map(int, input().split()))

ans = 0

def expect(n):
    res = 0
    for i in range(1, n+1):
        res += i
    res /= n
    return res

p = list(map(expect, p))

for i in range(n-k+1):
    target = p[i:i+k]
    ans = max(ans, sum(target))

print(ans)






### FIXED CODE ###

n, k = list(map(int, input().split()))
p = list(map(int, input().split()))


def expect(n):
    res = (n + 1) / 2
    return res

p = list(map(expect, p))
ans_sum = sum(p[:k])
tmp_sum = ans_sum
idx = 0

for i in range(k, n):
    tmp_sum = tmp_sum + p[i] - p[i-k]
    if tmp_sum > ans_sum:
        ans_sum = tmp_sum

print(ans_sum)
### BUGGY CODE ###

N = int(raw_input())
a = map(int,raw_input().split())
con = 0
i = 0
while i <= N:
  if len(a)==0:
    con = -1
    print con
    break
  elif len(a)==con:
    print N-con
    break
  if a[con] == con+1:
    con = con + 1
  else:
    a.pop(con)
  i= i+1

### FIXED CODE ###

N = int(raw_input())
a = map(int,raw_input().split())
con = 1
ans = 0
for i in range(0,N):
  if a[i] == con:
    con = con + 1
    continue
  else:
    ans = ans + 1
if ans == N:
  print -1
else:
  print ans
### BUGGY CODE ###

import math

def func(A, B, x):
    return math.floor(A*x/B)-A*math.floor(x/B)

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

i = 1
max_x = -9999999
max = -9999999
while (i <= N):
    ans =func(A, B, i) 
    if (ans > max):
        max = ans
        max_x = i

print(max)

### FIXED CODE ###

import math

def func(A, B, x):
    return math.floor(A*x/B)-A*math.floor(x/B)

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

"""
i = 1
max_x = -9999999
max = -9999999
while (i <= N):
    ans =func(A, B, i) 
    if (ans > max):
        max = ans
        max_x = i
    i += 1

print(max)
"""

print(func(A, B, min(B-1, N)))
### BUGGY CODE ###

from collections import defaultdict
def main():
    N = int(input())
    X = [int(a) for a in input().split()]
    X_s = sorted(X)

    medi = defaultdict(int)

    for i in range(len(X)):
        if X[i] in medi.keys():
            print(medi[X[i]])
        else:
            dummy = X_s[:]
            dummy.remove(X[i])
            m = dummy[len(dummy) // 2]
            print(m)
            medi[X[i]] = m

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    N = int(input())
    X = [int(a) for a in input().split()]
    Xs = sorted(X)

    for i in range(len(X)):
        if  Xs[len(Xs)//2] > X[i]:
            print(Xs[len(Xs)//2])
        else:
            print(Xs[len(Xs)//2 - 1])

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

#encoding utf:8

n = int(input())
# num=[]
num = list(int(i) for i in input().split())
# for i in range(n):
#     num.append(int(input().split()))

#gcd 最大公約数
def gcd(a,b):
    gcd = 1
    list_a = []
    list_b = []
    for i in range(a):
        if a % (i+1) ==0:
            a = a/(i+1)
            list_a.append(i+1)
    for i in range(b):
        if b % (i+1) ==0:
            b = b/(i+1)
            list_b.append(i+1)
    # print(list_a,list_b)
    for num in range(len(list_a)):
        if list_a[num] in list_b:
            gcd = gcd * list_a[num]
    return int(gcd)

# lcm: 最小公倍数
def lcm(a,b):
    lcm = a*b/gcd(a,b)
    return int(lcm)

for i in range(n):
    if i == 0:
        a_lcm = lcm(num[0], num[1])
    a_lcm = lcm(a_lcm,num[i])

max = a_lcm-1
f=0
for i in range(len(num)):

    f += (max%num[i])
print(f)


### FIXED CODE ###

n = int(input())
# num=[]
num = list(int(i) for i in input().split())

f = sum(num)-n
print(f)
### BUGGY CODE ###


def gcd(p, q):
    if(p%q ==0): 
        return q
    return gcd(q, p%q)

def main():
    ans = 0
    k = int(input())
    for i in range(k):
        for j in range(k):
            for l in range(k):
                ans += gcd(i+1,gcd(j+1,l+1))
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

from math import gcd
def main():
    ans = 0
    k = int(input())
    for i in range(k):
        for j in range(k):
            for l in range(k):
                ans += gcd(i+1,gcd(j+1,l+1))
    print(ans)


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



N = int(input())
S = input()
S = S[::-1]

cnt = 0
for i in range(1,N-1):
    for j in range(i+1,N):
        if S[i-1] != S[j-1]:
            for k in range(j+1,N+1):
                if S[i-1]!=S[k-1] and S[j-1]!=S[k-1] and j-i!=k-j:
                    cnt += 1

print(cnt)

### FIXED CODE ###



N = int(input())
S = input()
S = S[::-1]

cnt = S.count('B')*S.count('G')*S.count('R')

for i in range(N-2):
    for j in range(i,N-1):
        k = 2*j-i
        if  k<=N-1:
            if S[i]!=S[j] and S[i]!=S[k] and S[j]!=S[k] :
                cnt -= 1


print(cnt)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N, D, A = map(int, input().split())
S = [0]*N
for i in range(N):
    x, h = map(int, input().split())
    if h % A == 0:
        h //= A
    else:
        h = h//A + 1
    S[i] = [x, h]

S.sort()
print()
cnt = 0

for i in range(N):
    if S[i][1] <= 0:
        continue
    cnt += S[i][1]
    dmg = S[i][1]
    max_X = S[i][0] + D*2
    for j in range(i+1, N):
        if S[j][0] > max_X:
            break
        S[j][1] -= dmg

print(cnt)


### FIXED CODE ###

from collections import deque
import math

import sys
input = sys.stdin.readline

N, D, A = map(int, input().split())
S = [0]*N
atack = deque()
for i in range(N):
    x, h = map(int, input().split())
    S[i] = [x, h]

S.sort()
cnt = 0
dmg = 0
for i in range(N):
    while atack:
        if atack[0][0] < S[i][0]:
            x, d = atack.popleft()
            dmg -= d
        else:
            break

    if S[i][1] <= dmg:
        continue
    bomb = math.ceil((S[i][1]-dmg)/A)
    atack.append([S[i][0]+2*D, A*bomb])
    cnt += bomb
    dmg += A*bomb

print(cnt)
### BUGGY CODE ###

from collections import deque
H, W = map(int, input().split())
graph = [['#'] * (W+2) for _ in range(H+2)]
for i in range(H):
  S = input()
  for j in range(W):
    graph[i+1][j+1] = S[j]

def dfs(sx, sy, gx, gy):
  q = deque([(sx, sy)])
  dist = [[-1] * (W+2) for _ in range(H+2)]
  dist[sx][sy] = 0
  while q:
    x, y = q.popleft()
    dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    for dx, dy in dxy:
      nextx = x+dx
      nexty = y+dy
      if(dist[nextx][nexty] >= 0):
        continue
      if(graph[nextx][nexty] == '#'):
        continue
      dist[nextx][nexty] = dist[x][y] + 1
      q.append((nextx, nexty))
  return dist[gx][gy]

ans = 0  
for sx in range(1, H+1):
  for sy in range(1, W+1):
    for gx in range(1, H+1):
      for gy in range(1, W+1):
        if(graph[sx][sy] == '.' and graph[gx][gy] == '.'):
          tmp = dfs(sx, sy, gx, gy)
          ans = max(ans, tmp)
          
print(ans)

### FIXED CODE ###

def main():
  from collections import deque
  H, W = map(int, input().split())
  graph = [['#'] * (W+2) for _ in range(H+2)]
  for i in range(H):
    S = input()
    for j in range(W):
      graph[i+1][j+1] = S[j]

  def dfs(sx, sy):
    q = deque([(sx, sy)])
    dist = [[-1] * (W+2) for _ in range(H+2)]
    dist[sx][sy] = 0
    s = 0
    while q:
      x, y = q.popleft()
      dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
      for dx, dy in dxy:
        nextx = x+dx
        nexty = y+dy
        if(dist[nextx][nexty] >= 0):
          continue
        if(graph[nextx][nexty] == '#'):
          continue
        dist[nextx][nexty] = dist[x][y] + 1
        q.append((nextx, nexty))
    for i in range(H+2):
      for j in range(W+2):
        if(dist[i][j] >= 0):
          s = max(s, dist[i][j])
    return s

  ans = 0  
  for sx in range(1, H+1):
    for sy in range(1, W+1):
      if(graph[sx][sy] == '.'):
          tmp = dfs(sx, sy)
          ans = max(ans, tmp)
          
  print(ans)
  
main()
### BUGGY CODE ###

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

buff = []
a = []
for i in range(N):
    _a, _b = list(map(int, input().split()))
    buff += [_a]*_b


buff = sorted(buff)
print(buff[K-1])




### FIXED CODE ###

amax = 100000
cnt = [0 for i in range(amax+1)]


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

for i in range(N):
    a, b = list(map(int, input().split()))
    cnt[a] += b


for ans in range(1, amax+1):
    if K <= cnt[ans]:
        print(ans)
        break
    K -= cnt[ans]
### BUGGY CODE ###

import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
s = input()

t = []

ans = 0
def dfs(a, n):
    global ans, s
    if len(t) == 3:
        i, j, k = t[0], t[1], t[2]
        if j - i == k - j:
            return
        i -= 1
        j -= 1
        k -= 1
        if s[i] == s[j] or s[i] == s[k] or s[j] == s[k]:
            return
        ans += 1
        return
    for i in range(a, n + 1):
        t.append(i)
        dfs(i + 1, n)
        t.pop()

dfs(1, n)
print(ans)


### FIXED CODE ###

import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
s = input()

counter = [(0, 0, 0)]
for c in s:
    rgb = counter[-1]
    r, g, b = 0, 0, 0
    if c == 'R':
        r = 1
    if c == 'G':
        g = 1
    if c == 'B':
        b = 1
    new_rgb = (rgb[0] + r, rgb[1] + g, rgb[2] + b)
    counter.append(new_rgb)

ans = 0
MAX = 4002
x = []
for i in range(1, min(len(s) + 1, MAX)):
    for j in range(i + 1, min(len(s) + 1, MAX)):
        if s[i - 1] == s[j - 1]:
            continue
        x.append((i, j))

y = []
for p in x:
    i = p[0]
    j = p[1]
    rgb = {'R', 'G', 'B'}
    sub = {s[i - 1], s[j - 1]}

    k_s = rgb.difference(sub).pop()
    k_idx = 0
    if k_s == 'R':
        k_idx = 0
    if k_s == 'G':
        k_idx = 1
    if k_s == 'B':
        k_idx = 2

    j_cnt = counter[j]
    k_cnt = counter[len(s)]
    omit = 0
    if (2 * j - i) <= len(s):
        omit = counter[2* j - i][k_idx] - counter[2 * j - i - 1][k_idx]
    ans += (k_cnt[k_idx] - j_cnt[k_idx] - omit)

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

n = (int)(input())
s = (input())

l = len(s)
ans = l
for i in range(l):
  l_we = s[0:i] if(i >= 0)else None
  l_ea = s[i+1:l] if(i+1 <= l) else None
  tmp = 0
  tmp += l_we.count('W')
  tmp += l_ea.count('E')
  ans = min(ans, tmp)
print(ans)


### FIXED CODE ###

def sum_list(l1, l2):
  for i in range(len(l1)):
    l1[i] += l2[i]

  return l1


n = (int)(input())
s = input()
l_e = [0 for _ in range(n+1)]
l_w = [0 for _ in range(n+1)]

for i in range(n):
  if s[i] == 'W':
    l_e[i] += 1
  l_e[i+1] = l_e[i]

for i in reversed(range(n)):
  if s[i] == 'E':
    l_w[i] += 1
  l_w[i-1] = l_w[i]

l_e = l_e[:-1]
l_w = l_w[:n]


#print("E", l_e)
#print("W", l_w)

print(min(sum_list(l_e, l_w))-1)
### BUGGY CODE ###

def divisors(n):
   d=[]
   for i in range(1,int(n**0.5)+1):
       if n%i==0:
           d.append(i)
           if i!=n//i:
               d.append(n//i)
   d.sort()
   return d
n=int(input())
table=[0]*(n+1)
ball=[]
a=list(map(int,input().split()))[::-1]
for i in range(n):
    if table[n-i]!=a[i]:
        ball.append(n-i)
        for j in divisors(n-i):
            table[j]=1-table[j]
print(len(ball))
if len(ball)!=0:
    print(*ball)

### FIXED CODE ###

def divisors(n):
   d=[]
   for i in range(1,int(n**0.5)+1):
       if n%i==0:
           d.append(i)
           if i!=n//i:
               d.append(n//i)
   d.sort()
   return d
n=int(input())
table=[0]*(n+1)
ball=[]
a=list(map(int,input().split()))[::-1]
for i in range(n):
    if table[n-i]!=a[i]:
        ball.append(n-i)
        for j in divisors(n-i):
            table[j]=1-table[j]
print(len(ball))
if len(ball)!=0:
    print(*ball)
### BUGGY CODE ###

from collections import defaultdict

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

prime = defaultdict(int)
m = M
for i in range(2, M + 1):
    while m % i == 0 and m > 1:
        prime[i] += 1
        m //= i

MOD = 10 ** 9 + 7

def comb(n, k):
    a = 1
    for i in range(1, k + 1):
        a *= n - i + 1
        a %= MOD
        
        a *= pow(i, MOD - 2, MOD)
        a %= MOD
        
    return a

ans = 1
for _, t in prime.items():
    ans *= comb(N - 1 + t, t)
    ans %= MOD
    
print(ans)



### FIXED CODE ###

from collections import defaultdict

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

prime = defaultdict(int)
m = M
for i in range(2, 10 ** 5):
    while m % i == 0 and m > 1:
        prime[i] += 1
        m //= i

if m > 1:
    prime[10 ** 9] = 1
MOD = 10 ** 9 + 7

def comb(n, k):
    a = 1
    for i in range(1, k + 1):
        a *= n - i + 1
        a %= MOD
        
        a *= pow(i, MOD - 2, MOD)
        a %= MOD
        
    return a

ans = 1
for _, t in prime.items():
    ans *= comb(N - 1 + t, t)
    ans %= MOD
    
print(ans)
### BUGGY CODE ###

n,m,s,t=map(int,input().split())
import numpy as np
import sys
def input(): return sys.stdin.readline().strip()
u,v,a,b=map(np.array,zip(*[map(int,input().split()) for i in range(m)]))
from scipy.sparse import csr_matrix
g1=csr_matrix((a,(u-1,v-1)),shape=(n,n))
g2=csr_matrix((b,(u-1,v-1)),shape=(n,n))
from scipy.sparse.csgraph import dijkstra
d1=dijkstra(g1,directed=False,indices=s-1)
d2=dijkstra(g2,directed=False,indices=t-1)
D=np.ones(n)*10**15-d1-d2
r=[0]*n
for i in range(n):
    r[-i-1]=max(r[-i],int(D[-i-1]))
print(*r,sep='\n')

### FIXED CODE ###

n,m,s,t=map(int,input().split())
uvab=[map(int,input().split()) for i in range(m)]
inf=10**20
c1=[[] for i in range(n)]
c2=[[] for i in range(n)]
for u,v,a,b in uvab:
    c1[u-1].append((v-1,a))
    c1[v-1].append((u-1,a))
    c2[u-1].append((v-1,b))
    c2[v-1].append((u-1,b))
from heapq import heappop,heappush
def dij(c,N,start):
    d=[inf]*N
    d[start]=0
    prev=[-1]*N
    q=[]
    heappush(q,(0,start))
    while len(q)>0:
        u=heappop(q)[1]
        for v,w in c[u]:
            if w<inf:
                temp=d[u]+w
                if d[v]>temp:
                    d[v]=temp
                    prev[v]=u
                    heappush(q,(d[v],v))
    return d
d1=dij(c1,n,s-1)
d2=dij(c2,n,t-1)
r=[0]*n
for i in range(n):
    r[-i-1]=max(r[-i],10**15-int(d1[-i-1])-int(d2[-i-1]))
print(*r,sep='\n')
### BUGGY CODE ###

from collections import*
H,W=map(int,input().split());M=[input()for _ in"_"*H];C=[[999]*W for _ in"_"*H];C[0][0]=0;q=deque([[0,0]])
while q:
  x,y=q.popleft()
  for i,j in [[1,0],[0,1]]:
    h,w=x+i,y+j
    if H>h and W>w:C[h][w]=min([C[h-1][w]+(M[h-1][w]<"."),999][0>h],[C[h][w-1]+(M[h][w-1]<"."),999][0>w]);q.append([h,w])
print(C[-1][-1]+(M[-1][-1]<"."))

### FIXED CODE ###

H,W=map(int,input().split());M=[input()for _ in"_"*H];D=[[0]*-~W for _ in"_"*-~H]
for i in range(H):
  for j in range(W):
    a=b=999
    if i>0:a=D[i][j+1]+(M[i-1][j]>M[i][j])
    if j>0:b=D[i+1][j]+(M[i][j-1]>M[i][j])
    D[i+1][j+1]=min(a,b,999*(i+j>0))
print(D[-1][-1]+(M[0][0]<"."))
### BUGGY CODE ###

import queue

def bfs():
    while queueX.empty() == False:
        x = queueX.get()
        y = queueY.get()

        for i in range(4):
            nextX = x + moveR[i]
            nextY = y + moveC[i]
            if 0 <= nextX and nextX < H\
                and 0 <= nextY and nextY < W\
                and s[nextX][nextY] != '#'\
                and s[nextX][nextY] == '.':
                    s[nextX][nextY] = s[x][y] + 1
                    queueX.put(nextX)
                    queueY.put(nextY)

H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
moveR = [0, 1, -1, 0]
moveC = [1, 0, 0, -1]

queueX = queue.Queue()
queueY = queue.Queue()
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            queueX.put(i)
            queueY.put(j)
            s[i][j] = 0
bfs()
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, s[i][j])
print(ans)

### FIXED CODE ###

from collections import deque

def bfs():
    while len(que) != 0:
        p = que.popleft()
        for i in range(4):
            nextX = p[0] + moveR[i]
            nextY = p[1] + moveC[i]
            if 0 <= nextX and nextX < H\
                and 0 <= nextY and nextY < W\
                and s[nextX][nextY] != '#'\
                and s[nextX][nextY] == '.':
                s[nextX][nextY] = s[p[0]][p[1]] + 1
                que.append([nextX, nextY])

H, W = map(int, input().split())
s = [list(input()) for _ in range(H)]
moveR = [0, 1, -1, 0]
moveC = [1, 0, 0, -1]

que = deque()
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            que.append([i, j])
            s[i][j] = 0
bfs()
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, s[i][j])
print(ans)
### BUGGY CODE ###

def main():
  n,k = map(int,input().split())
  h = list(map(int,input().split()))
  dp= [0]*n

  for i in range(1,n):  
    dp[i] =min([dp[i-j] + abs(h[i] - h[i-j]) \
                for j in range(1,min(i+1,k+1))])       
  print(dp[-1])  

if __name__=='__main__':
  main()

### FIXED CODE ###

# TLE
n,k = map(int,input().split())
h = list(map(int,input().split()))
dp= [0]*n

for i in range(1,n):
  tmp = float('inf')
  for j in range(1,min(i+1,k+1)):    
    d = dp[i-j] + abs(h[i] - h[i-j])    
    tmp = min(tmp,d)  
  dp[i] = tmp
  
print(dp[-1])
### BUGGY CODE ###

s = input()
count = 0

while s.find("01") != -1 or s.find("10") != -1:
    count += 2 * s.count("01")
    s = s.replace("01", "")
    count += 2 * s.count("10")
    s = s.replace("10", "")
print(count)


### FIXED CODE ###

s = input()
print(2 * min(s.count("0"), s.count("1")))
### BUGGY CODE ###

def inpl(): return [int(i) for i in input().split()]

N,A,B = inpl()
C = A-B
h = [int(input()) for _ in range(N)]

ans = -(-sum(h)//((N-1)*B+A))
while True:
    hprime = [h[i]-ans*B for i in range(N) if h[i]-ans*B >0]
    hans = ans    
    for j in hprime:
            hans -= -(-j//C)
    if hans >= 0:
        break
    ans += 1
print(ans)    

### FIXED CODE ###

def inpl(): return [int(i) for i in input().split()]

N,A,B = inpl()
C = A-B
h = [int(input()) for _ in range(N)]

lo = -(-sum(h)//((N-1)*B+A)) -1
hi = sum([-(-i//A) for i in h]) 
while hi - lo > 1:
    me = (hi+lo)//2
    hprime = [h[i]-me*B for i in range(N) if h[i]-me*B >0]    
    hans = 0
    for j in hprime:
            hans += -(-j//C)
    if hans <= me:
        hi = me
    else:
        lo = me
print(hi)
### BUGGY CODE ###

#!/usr/bin/env python3

import collections
import sys
input=sys.stdin.readline

r,c,k=map(int,input().split())
items=collections.defaultdict(int)
for _ in range(k):
    tr,tc,tv=map(int,input().split())
    items[(tr,tc)]=tv
dp=[[[0]*4 for _ in range(c+1)] for _ in range(r+1)]
for i in range(1,r+1):
    for j in range(1,c+1):
        tv=items[(i,j)]
        left_max=max(dp[i-1][j])
        #左から来るときは取った個数をリセットする
        dp[i][j][0]=max(dp[i][j-1][0],left_max)
        dp[i][j][1]=max(dp[i][j-1][1],dp[i][j-1][0]+tv,left_max+tv)        
        dp[i][j][2]=max(dp[i][j-1][2],dp[i][j-1][1]+tv)
        dp[i][j][3]=max(dp[i][j-1][3],dp[i][j-1][2]+tv)
print(max(dp[r][c]))

### FIXED CODE ###

#!/usr/bin/env python3

import sys
input=sys.stdin.readline

r,c,k=map(int,input().split())
items=[0]*(r*c)
for _ in range(k):
    tr,tc,tv=map(int,input().split())
    items[c*(tr-1)+tc-1]=tv
dp=[0]*(4*r*c)
for i in range(1,r+1):
    for j in range(1,c+1):
        tv=items[c*(i-1)+j-1]
        change_pos=4*(c*(i-1)+j-1)
        left_pos=4*(c*(i-2)+j-1)
        up_pos=4*(c*(i-1)+j-2)
        if i!=1:
          left_max=max(dp[left_pos],dp[left_pos+1],dp[left_pos+2],dp[left_pos+3])
        else:
          left_max=0
        if j!=1:
          dp[change_pos]=max(dp[up_pos],left_max)
          dp[change_pos+1]=max(dp[up_pos+1],dp[up_pos]+tv,left_max+tv)        
          dp[change_pos+2]=max(dp[up_pos+2],dp[up_pos+1]+tv)
          dp[change_pos+3]=max(dp[up_pos+3],dp[up_pos+2]+tv)
        else:
          dp[change_pos]=left_max
          dp[change_pos+1]=left_max+tv
print(max(dp[-1],dp[-2],dp[-3],dp[-4]))
### BUGGY CODE ###

import copy

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

asum = [0]
bsum = [0]
tmp = 0
for i in range(n):
    tmp += a[i]
    asum.append(tmp)
tmp = 0
for i in range(m):
    tmp += b[i]
    bsum.append(tmp)


ans = 0
for na in range(n+1):
    res = k - asum[na]
    if res < 0:
        break
    flg = True
    nb = copy.deepcopy(m)
    while flg:
        if bsum[nb] > res:
            nb -= 1
            continue
        ans = max(ans, na+nb)
        break
print(ans)

### FIXED CODE ###

import copy

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

asum = [0]
bsum = [0]
tmp = 0
for i in range(n):
    tmp += a[i]
    asum.append(tmp)
tmp = 0
for i in range(m):
    tmp += b[i]
    bsum.append(tmp)


ans = 0
nb = copy.deepcopy(m)
for na in range(n+1):
    res = k - asum[na]
    if res < 0:
        break
    flg = True
    while flg:
        if bsum[nb] > res:
            nb -= 1
            continue
        ans = max(ans, na+nb)
        break
print(ans)