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

N=int(input())
S=input()
count=0
for i in range(N):
    for j in range(N):
        for k in range(N):
            if i<j and j<k and(j-i)!=(k-j) and S[i]!=S[j] and S[j]!=S[k] and S[k]!=S[i]:
                count+=1
print(count)


### FIXED CODE ###

N=int(input())
S=input()
# N=int(Input[0][0])
# S=Input[1][0]
import math
count=0
counter={'R':0,'G':0,'B':0}
for i in S:
    counter[i]+=1
s=counter['R']*counter['G']*counter['B']
for i in range(1,N-1):
    for j in range(i+1,N):
        k=2*j-i
        if k<=N and (S[i-1]!=S[j-1] and S[i-1]!=S[k-1] and S[j-1]!=S[k-1]):
                count+=1
print(s-count)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = [1]
    for i in range(1,K + 1):
        a = A[B[i - 1] - 1]
        if a in B:
            x = B.index(a)
            y = i - x
            z = (K - x) % y
            print(B[x + z])
            exit()
        B.append(a)
    if len(B) == K + 1:
        print(B[K])
if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    B = [1]
    a = 1
    check = [0] * len(A)
    while True:
        a = A[a - 1]
        if check[a - 1] == 1:
            x = B.index(a)
            roop = B[x:]
            print(roop[(K - x) % len(roop)])
            exit()
        B.append(a)
        check[a - 1] += 1
        if len(B) >= K + 1:
            print(B[K])
            exit()
if __name__ == '__main__':
    main()
### BUGGY CODE ###

s=input()
K=int(input())
p=set()
for i in range(len(s)):
  for j in range(i,len(s)):
    p.add(s[i:j+1])
p=sorted(p)
print(p[K-1])

### FIXED CODE ###

s=input()
s=s+'0'
K=int(input())
p=set()
for i in range(len(s)):
  for j in range(1,6):
    if i+j<=len(s)-1:
      p.add(s[i:j+i])
p=sorted(p)
print(p[K-1])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

import heapq
n = int(input())
l = [[0, 0] for i in range(n)]
for i in range(n):
  x, y = map(int, input().split())
  l[i][0] = x
  l[i][1] = y
  
graph = []
for i in range(n-1):
  x1, y1 = l[i]
  for j in range(i, n):
    x2, y2 = l[j]
    graph.append((min(abs(x1-x2), abs(y1-y2)), i, j))
    graph.append((min(abs(x1-x2), abs(y1-y2)), j, i))

#union find
def Find(x, par):
  if par[x] < 0:
    return x
  else:
    # 経路圧縮
    par[x] = Find(par[x], par)
    return par[x]

def Unite(x, y, par, rank):
  x = Find(x, par)
  y = Find(y, par)
  
  if x != y:
    # rankの低い方を高い方につなげる
    if rank[x] < rank[y]:
      par[y] += par[x]
      par[x] = y
    else:
      par[x] += par[y]
      par[y] = x
      if rank[x] == rank[y]:
        rank[x] += 1
    
def Same(x, y, par):
  return Find(x, par) == Find(y, par)
 
def Size(x, par):
  return -par[Find(x)]

#print(graph)
graph.sort()
par = [-1]*n
rank = [0]*n

cost = 0

for d, p, q in graph:
  if not Same(p, q, par):
    cost += d
    Unite(p, q, par, rank)

print(cost)

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

n = int(input())
P = []
for i in range(n):
    x, y = map(int, input().split())
    P.append((x, y, i))

import heapq
def prim_heap():
    used = [True]*n
    edgelist = []
    for e in edge[0]:
        heapq.heappush(edgelist, e)
        used[0] = False
    res = 0
    while len(edgelist) != 0:
        minedge = heapq.heappop(edgelist)
        if not  used[minedge[1]]:
            continue
        v = minedge[1]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist, e)
        res += minedge[0]
    return res

P.sort()
edge = [[] for _ in range(n)]
for i in range(n-1):
    d = min(abs(P[i+1][0]-P[i][0]), abs(P[i+1][1]-P[i][1]))
    edge[P[i][2]].append((d, P[i+1][2]))
    edge[P[i+1][2]].append((d, P[i][2]))

P.sort(key = lambda x: x[1])
for i in range(n-1):
    d = min(abs(P[i+1][0]-P[i][0]), abs(P[i+1][1]-P[i][1]))
    edge[P[i][2]].append((d, P[i+1][2]))
    edge[P[i+1][2]].append((d, P[i][2]))

print(prim_heap())
### BUGGY CODE ###

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

ans = 0

for x in range(1,n+1):
    if ans > ((a*x//b)-(x//b)*a):
        break
    else:
        ans = max(ans, (a*x//b)-(x//b)*a)

print(ans)

### FIXED CODE ###

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


x = min(n,b-1)
print((a*x//b)-(x//b)*a)
### BUGGY CODE ###

def main():
  n, m = map(int, input().split())
  data = [[int(e) for e in input().split()] for _ in range(n)]
  d1 = {}
  for i in range(n):
    a, b = data[i]
    if a not in d1:
      d1[a] = []
    d1[a].append(b)
  result = 0
  d2 = {}
  for i in range(1, m + 1):
    if i in d1:
      for j in d1[i]:
        if j not in d2:
          d2[j] = 0
        d2[j] += 1
    else:
      if len(d2) == 0:
        continue
    maxb = max(d2.keys())
    result += maxb
    if d2[maxb] == 1:
      del d2[maxb]
  print(result)
main()


### FIXED CODE ###

n, m = map(int, input().split())
d1 = {}
for _ in range(n):
  a, b = map(int, input().split())
  if a in d1:
    d1[a].append(b)
  else:
    d1[a] = [b]
result = 0
d2 = {}
maxb = -1
for i in range(1, m + 1):
  if i in d1:
    for j in d1[i]:
      if j not in d2:
        d2[j] = 0
      d2[j] += 1
      if j > maxb:
        maxb = j
  else:
    if len(d2) == 0:
      continue
  result += maxb
  if d2[maxb] == 1:
    del d2[maxb]
    if len(d2) == 0:
      maxb = 0
    else:
      maxb = max(d2.keys())
  else:
    d2[maxb] -= 1
print(result)
### BUGGY CODE ###

# ABC132 E
from collections import deque

f=lambda:map(int,input().split())
N,M=f()
KKP=[[[] for _ in [0]*(N+1)] for _ in [0]*3]
for _ in [0]*M:
    a,b=f()
    KKP[0][a].append(b)
S,T=f()

for j in range(2):
    # j:回数
    for a in range(1,N+1):
        # a:頂点
        for b in KKP[j][a]:
            # KKP[j][a]:aからj+1回でたどり着ける頂点 b
            for c in KKP[0][b]:
                # bから1回でたどり着ける頂点 c
                if not c in KKP[j+1][a]:
                    KKP[j+1][a].append(c)

F=set([])
q=deque()
q.append((S,0))
res=-1
while q:
    node,score=q.popleft()
    if node in F:
        continue
    if T==node:
        res=score
        break
    F.add(node)
    for nnode in KKP[2][node]:
        if nnode in F:
            continue
        q.append((nnode,score+1))
print(res)

### FIXED CODE ###

# ABC132 E
from collections import deque

f=lambda:map(int,input().split())
N,M=f()
G=[[] for _ in [0]*(N+1)]

for _ in [0]*M:
    a,b=f()
    G[a].append(b)
S,T=f()
S=(S,0)
T=(T,0)

q=deque()
q.append(S)
F=set()
res=-1
while q:
    node,r=q.popleft()
    if (node,r%3) in F:
        continue
    if (node,r%3) == T:
        res=r//3
        break
    F.add((node,r%3))
    for next_node in G[node]:
        if (next_node,(r+1)%3) in F:
            continue
        q.append((next_node,r+1))
print(res)
### BUGGY CODE ###

N = int(input())
D = list(map(int, input().split()))
D.sort()
ans = 0
for i in range(D[N // 2 - 1], max(D)) :
  cnt = len(list(filter(lambda x : x <= i, D)))
  if(cnt == N // 2) :
    ans += 1
  elif(cnt > N // 2) :
    break
  else :
    pass
print(ans)

### FIXED CODE ###

N = int(input())
D = list(map(int, input().split()))
D.sort()
ans = 0
for i in range(N // 2) :
  cnt = len(list(filter(lambda x : x <= D[N // 2 - 1 + i], D)))
  if(cnt == N // 2) :
    ans += D[N // 2] - D[N // 2 - 1]
  elif(cnt > N // 2) :
    break
  else :
    pass
print(ans)
### BUGGY CODE ###

from functools import reduce

n, k = map(int, input().split())
a = list(map(int, input().split()))
score = [0] * (n+1)

for i in range(k, n+1):
    score[i] = reduce(lambda x, y: x*y, a[i-k:i], 1)
    if i == k:
        continue
    print('Yes' if score[i-1] < score[i] else 'No')


### FIXED CODE ###

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

for i in range(k, n+1):
    if i == k:
        continue
    print('Yes' if a[i-k-1] < a[i-1] else 'No')
### BUGGY CODE ###

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

ans = 1


for i in range(len(a)):
    if 0 in a:
        ans =0
        break
    ans = ans * a[i]
    if ans >10**18:
        break


if ans >10**18:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

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

ans = 1
list.sort(a, reverse = True)
ones = a.count(1)
for i in range(len(a)-ones):
    if 0 in a:
        ans =0
        break
    ans = ans * a[i]
    if ans >10**18:
        break

if ans >10**18:
    print(-1)
else:
    print(ans)
### BUGGY CODE ###

inputs = input().split(' ')
a = int(inputs[0])
b = int(inputs[1])
n = int(inputs[2])

output = 0
for x in range(1, n + 1):
    if x % b == 0:
        break
    buf = (a*x//b) - a*(x//b)
    if buf > output:
        output = buf

print(output)

### FIXED CODE ###

inputs = input().split(' ')
a = int(inputs[0])
b = int(inputs[1])
n = int(inputs[2]) + 1

x = (n if n < b else b) - 1
output = (a*x//b)

print(output)
### BUGGY CODE ###

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

parent=[i for i in range(M)]
depth=[0 for i in range(M)]

def root(x):
  temp=x
  while x!=parent[x]:
    x=parent[x]
  parent[temp]=x
  return parent[x]
  
def same(x,y):
  return root(x)==root(y)

def union(x,y):
  x=root(x)
  y=root(y)
  if x==y:
    return
  if depth[x]>depth[y]:
    parent[y]=x
  else:
    parent[x]=y
    if depth[x]==depth[y]:
      depth[x]+=1
      
h=[None]*N
langs=set()
for i in range(N):
  k,*h=map(int,input().split())
  for j in range(k-1):
    langs.add(h[j]-1)
    union(h[j]-1,h[j+1]-1)
  langs.add(h[k-1]-1)
  
roots=set()
for l in langs:
  roots.add(root(l))
  
print(("NO","YES")[len(roots)==1])

### FIXED CODE ###

# 人も言語もグラフの頂点と見なす
# ある人がある言語を話せる場合連結となる
# 頂点のキーは[言語 or 人][番号(人番号 or 言語番号)]
# 0:言語 1:人

N,M = map(int,input().split())
from collections import defaultdict
E = [[],[]]
E[0] = [[] for i in range(M)]
E[1] = [[] for i in range(N)]

for i in range(N):
  langs = list(map(int,input().split()))[1:]
  for lang in langs:
    E[1][i].append((0,lang-1))
    E[0][lang-1].append((1,i))
    
# 任意の頂点からBFSして、全ての人の頂点が往訪済みになればOK
from collections import deque
q = deque([])
# 人で、0番目からスタート
q.append((1,0))
seen = [[],[]]
seen[0] = [False for i in range(M)]
seen[1] = [False for i in range(N)]

while q:
  kind,v = q.popleft()
  if seen[kind][v]:
    continue
  seen[kind][v] = True
  children = E[kind][v]
  for child in children:
    q.append([child[0],child[1]])
    
for s in seen[1]:
  if not s:
    print("NO")
    break
else:
  print("YES")
### BUGGY CODE ###

def main():
    N, M = map(int, input().split())
    A = [int(x) for x in input().split()]
    for m in range(0, M):
        tmp = [int(x) for x in input().split()]
        A.extend([tmp[1]] * tmp[0])
 
    A.sort()
    print(sum(A[-N:]))
 
 
if __name__ == "__main__":
    main()

### FIXED CODE ###

import numpy

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

a = numpy.array([int(e) for e in input().split(" ")],dtype=numpy.int64)
changes=[]
for i in range(m):
    changes.append([int(e) for e in input().split(" ")])


a.sort()
#昇順ソート

changes.sort(key=lambda x:(x[1],x[0]),reverse = True)

change_num = 0
for change in changes:
    for i in range(change_num, min(change[0] + change_num,n)):
        if a[i] < change[1]:
            change_num += 1
            a[i] = change[1]
        else:
            break

print(a.sum())
### BUGGY CODE ###

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


head = 0
i = 1

while True:
    if i in A[head:]:
        head = A[head:].index(i)
        i += 1
    else:
        break

if i == 1:
    print(-1)
else:
    print(len(A) - i + 1)


### FIXED CODE ###

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

length = len(A)
find_next = 1

for i in range(N):
    if A[i] == find_next:
        find_next += 1

if find_next == 1:
    print(-1)
else:
    print(length - find_next + 1)
### BUGGY CODE ###

# https://atcoder.jp/contests/abc141/tasks/abc141_d
from copy import deepcopy
from heapq import heappop, heappush, heapify
n, m = map(int, input().split())

nums = [-int(i) for i in input().split()]
heapify(nums)
def check(nums, money, m):
    while m:
        m -= 1
        item = -1 * heappop(nums)
        item //= 2
        nums.append(-1 * item)
    pay = 0
    for num in nums:
        pay += -1 * num
        if pay > money:
            return False
    return True
l = 0
r = -1 * sum(nums)
ans = r
while l <= r:
    items = deepcopy(nums)
    mid = (l + r) // 2
    if check(items, mid, m):
        ans = min(ans, mid)
        r = mid - 1
    else:
        l = mid + 1
print(ans)

### FIXED CODE ###

# https://atcoder.jp/contests/abc141/tasks/abc141_d
from copy import deepcopy
from heapq import heappop, heappush, heapify
n, m = map(int, input().split())

items = [-int(i) for i in input().split()]
heapify(items)
while m:
    m -= 1
    item = -1 * heappop(items)
    item //= 2
    heappush(items, -1 * item)
pay = 0
for i in items:
    pay += -1 * i
print(pay)
### BUGGY CODE ###

import itertools
k = int(input())
x = list(range(1,k+1))
y = list(itertools.product(x,repeat = 3))
n = len(y)
p = 0

for i in range(n):
    a = y[i][0]
    b = y[i][1]
    while b != 0:
        c = a % b
        a = b
        b = c
    b = y[i][2]
    while b != 0:
        c = a % b
        a = b
        b = c
    p += a

print(p)

### FIXED CODE ###

import math
import itertools

k = int(input())
l = list(range(1,k+1))
y = list(itertools.combinations_with_replacement(l,3))
n = len(y)
t = 0

for i in range(n):
    a = y[i][0]
    b = y[i][1]
    c = y[i][2]
    d = math.gcd(math.gcd(a,b),c)
    if a != b != c:
        t += d * 6
    elif a == b == c:
        t += d
    else:
        t += d * 3

print(t)
### BUGGY CODE ###

import sys
from collections import deque as dq
input = sys.stdin.readline
H, W, K = map(int, input().split())
x, y, u, v = map(int, input().split())
x -= 1
y -= 1
u -= 1
v -= 1
a = [list(input())[: -1] for _ in range(H)]
Q = dq([x * W + y])
inf = H * W + 1
dp = [inf] * (H * W)
dp[x * W + y] = 0
while len(Q):
  t = Q.popleft()
  p = t // W
  q = t % W
  for i in range(1, K + 1):
    pp = p + i
    if pp in range(H):
      if a[pp][q] == "@": break
      if dp[pp * W + q] <= dp[t]: break
      dp[pp * W + q] = dp[t] + 1
      Q.append(pp * W + q)
  for i in range(1, K + 1):
    pp = p - i
    if pp in range(H):
      if a[pp][q] == "@": break
      if dp[pp * W + q] <= dp[t]: break
      dp[pp * W + q] = dp[t] + 1
      Q.append(pp * W + q)

  for i in range(1, K + 1):
    qq = q + i
    if qq in range(W):
      if a[p][qq] == "@": break
      if dp[p * W + qq] <= dp[t]: break
      dp[p * W + qq] = dp[t] + 1
      Q.append(p * W + qq)

  for i in range(1, K + 1):
    qq = q - i
    if qq in range(W):
      if a[p][qq] == "@": break
      if dp[p * W + qq] <= dp[t]: break
      dp[p * W + qq] = dp[t] + 1
      Q.append(p * W + qq)
if dp[u * W + v] != inf: print(dp[u * W + v])
else: print(-1)


### FIXED CODE ###

import sys
from collections import deque as dq
input = sys.stdin.readline
H, W, K = map(int, input().split())
x, y, u, v = map(int, input().split())
x -= 1
y -= 1
u -= 1
v -= 1
a = [list(input())[: -1] for _ in range(H)]
Q = dq([(0, x * W + y)])
inf = H * W + 1
dp = [inf] * (H * W)
dp[x * W + y] = 0
while len(Q):
  cost, t = Q.popleft()
  dp[t] = cost
  p = t // W
  q = t % W
  if (p, q) == (u, v):
    print(cost)
    exit(0)
  for i in range(1, K + 1):
    pp = p + i
    if pp in range(H):
      if a[pp][q] == "@": break
      if dp[pp * W + q] <= dp[t]: break
      if dp[pp * W + q] != inf: continue
      dp[pp * W + q] = dp[t] + 1
      Q.append((dp[t] + 1, pp * W + q))
  for i in range(1, K + 1):
    pp = p - i
    if pp in range(H):
      if a[pp][q] == "@": break
      if dp[pp * W + q] <= dp[t]: break
      if dp[pp * W + q] != inf: continue
      dp[pp * W + q] = dp[t] + 1
      Q.append((dp[t] + 1, pp * W + q))

  for i in range(1, K + 1):
    qq = q + i
    if qq in range(W):
      if a[p][qq] == "@": break
      if dp[p * W + qq] <= dp[t]: break
      if dp[p * W + qq] != inf: continue
      dp[p * W + qq] = dp[t] + 1
      Q.append((dp[t] + 1, p * W + qq))

  for i in range(1, K + 1):
    qq = q - i
    if qq in range(W):
      if a[p][qq] == "@": break
      if dp[p * W + qq] <= dp[t]: break
      if dp[p * W + qq] != inf: continue
      dp[p * W + qq] = dp[t] + 1
      Q.append((dp[t] + 1, p * W + qq))
print(-1)
### BUGGY CODE ###

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)

N = getN()
dist = [[] for i in range(N + 1)]
for i in range(N - 1):
    a, b, c = getNM()
    dist[a].append([b, c])
    dist[b].append([a, c])
d = [[float('inf')] * (N + 1) for i in range(N + 1)]
ignore = [-1] * (N + 1)

# Kからの最短距離をbfsで測る
def distance(sta):
    # 木をKから順にたどる（戻るの禁止）
    pos = deque([sta])

    while len(pos) > 0:
        u = pos.popleft()
        for i in dist[u]:
            if ignore[i[0]] == -1:
                ignore[i[0]] = ignore[u] + i[1]
                pos.append(i[0])

Q, K = getNM()
ignore[K] = 0
distance(K)
# 答えはK~xまでの距離+K~yまでの距離
ans = []
for i in range(Q):
    x, y = getNM()
    ans.append(ignore[x] + ignore[y])
for i in ans:
    print(i)

### FIXED CODE ###

def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()

from collections import defaultdict, deque, Counter
from sys import exit
import heapq
import math
import copy
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)

N = getN()
dist = [[] for i in range(N + 1)]
for i in range(N - 1):
    a, b, c = getNM()
    dist[a].append([b, c])
    dist[b].append([a, c])
ignore = [-1] * (N + 1)

# Kからの最短距離をbfsで測る
def distance(sta):
    # 木をKから順にたどる（戻るの禁止）
    pos = deque([sta])

    while len(pos) > 0:
        u = pos.popleft()
        for i in dist[u]:
            if ignore[i[0]] == -1:
                ignore[i[0]] = ignore[u] + i[1]
                pos.append(i[0])

Q, K = getNM()
ignore[K] = 0
distance(K)
# 答えはK~xまでの距離+K~yまでの距離
ans = []
for i in range(Q):
    x, y = getNM()
    ans.append(ignore[x] + ignore[y])
for i in ans:
    print(i)
### BUGGY CODE ###

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

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

c = 0
for i in range(n):
	c += r.count(l[i])

print(c)

### FIXED CODE ###

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

l = [0]*n
r = [0]*n

l = [i+a[i] for i in range(n)]
r = [i-a[i] for i in range(n)]
ld = {}
rd = {}

c = 0

for i in range(n):
	if l[i] in ld:
		ld[l[i]] += 1
	else:
		ld[l[i]] = 1
	if r[i] in rd:
		rd[r[i]] += 1
	else:
		rd[r[i]] = 1

for i in ld.keys():
	if i in rd:
		c += ld[i]*rd[i]	
	
print(c)
### BUGGY CODE ###

input_d1 = int(input()) 
input_d2 = list(input().split())

c = sorted(input_d2)
c.append('0')
e = {'0':0}

for i in range(0,input_d1):
    if c[i] == c[i+1]:
        pass
    else:
        e[c[i]] = i + 1 - sum(e.values())

e.pop('0')
d = {}

for i in e.keys():
    d[i] = 1 - e[i] + sum(map(lambda x:x*(x-1)/2 , e.values()))


for i in input_d2:
    print(int(d[i]))

### FIXED CODE ###

input_d1 = int(input()) 
input_d2 = list(input().split())

c = sorted(input_d2)
c.append('0')
e = {'0':0}
g = [0]
s = 0

for i in range(0,input_d1):
    if c[i] == c[i+1]:
        pass
    else:
        g.append(i+1)
        e[c[i]] = i + 1 - g[s]
        s += 1

e.pop('0')
d = {}
f = sum(map(lambda x:x*(x-1)/2 , e.values()))

for i in e.keys():
    d[i] = 1 - e[i] + f


for i in input_d2:
    print(int(d[i]))
### BUGGY CODE ###

T=input()
for i in range(T):
	A,B,C,D=map(int,raw_input().split())
	if A<B:
		print "No"
	elif B>D:
		print "No"
	elif abs(B-C)==1:
		print "Yes"
	else:
		A=A%B

		while A<=B:
			if (D-B)%B==0:
				if A>C and A<B:
					print "No"
					break
				else:
					print "Yes"
					break
			elif (D-B)%B==1:
					print "No"
					break

			A+=(D-B)%B
			if A>C and A<B:
				print "No"
				break
		else:
			print "Yes"

### FIXED CODE ###

import fractions

def func(A,B,C,D):
#	print "A,B,C,D::",A,B,C,D

	if A<B:
		print "No"
	elif B>D:
		print "No"
	elif B<=C:
		print "Yes"

	else:
		A%=B
		g=fractions.gcd(B,D)
		if g==B:
			if A>C:
				print "No"
			else:
				print "Yes"
		elif B-g>C:
			print "No"
		else:
			print "Yes"
T=input()

for i in range(T):
	a,b,c,d=map(int, raw_input().split())
	func(a,b,c,d)
### BUGGY CODE ###

from collections import Counter

n = int(input())
box = list(map(int, input().split()))
c = Counter(box)

for b in box:
    c[b] -= 1
    cnt = 0
    for k in c.keys():
        #print('k, c[k]: ',k ,c[k])
        if c[k] != 1:
            cnt += int(1/2 * c[k] * (c[k] - 1))
    print(cnt)
    c[b] += 1


### FIXED CODE ###

from collections import defaultdict

n = int(input())
box = list(map(int, input().split()))
c = defaultdict(int)
for b in box:
    c[b] += 1
    
anss = sum([int(1/2 * c[k] * (c[k] - 1)) for k in c.keys()])
for b in box:
    fi = anss - int(1/2 * c[b] * (c[b] - 1)) + int(1/2 * (c[b]-1) * (c[b] - 2)) 
    print(fi)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
import math
# stdin = open("sample.txt")

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

K = int(stdin.readline().rstrip())
a = list(range(1,10))
b = []
attack = 100000
while attack > 0:
    go = a.pop(0)
    ue = go*10
    shimo = go%10
    b.append(go)
    if shimo == 0:
        a.append(ue)
        a.append(ue+1)
    elif shimo == 9:
        a.append(ue+shimo-1)
        a.append(ue+shimo)
    else:
        a.append(ue+shimo-1)
        a.append(ue+shimo)
        a.append(ue+shimo+1)
    attack -= 1

print(b[K-1])

### FIXED CODE ###

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque
import math
# stdin = open("sample.txt")

K = int(stdin.readline().rstrip())
a = deque(range(1,10))
ans_list = []
attack = 100000
while attack > 0:
    ans = a.popleft()
    ue = ans*10
    shimo = ans%10
    ans_list.append(ans)
    if shimo == 0:
        a.append(ue)
        a.append(ue+1)
    elif shimo == 9:
        a.append(ue+shimo-1)
        a.append(ue+shimo)
    else:
        a.append(ue+shimo-1)
        a.append(ue+shimo)
        a.append(ue+shimo+1)
    attack -= 1

print(ans_list[K-1])
### BUGGY CODE ###

import math
n, a, b = map(int, input().split())
d = []
for i in range(n):
    d.append(input())
# [d1, d2, d3, ..., dN]
h = [int(m) for m in d]#int型に直す
#print(x)

low = 0
high = 10**9
# t は中央番目の数
t = (low + high) // 2

# 探索の下限のlowが上限のhighになるまで探索
# lowがhighに達すると数は見つからなかっTrueたということ
X = 0
Y = 0
while True:
    for j in range(n):
        X += math.ceil((h[j] - t * b) / (a - b))
    if X <= t:
        for j in range(n):
            Y += math.ceil((h[j] - (t - 1) * b) / (a - b))
        if Y > t - 1:
            print(t)
            exit()
        else:
            high = t - 1
    elif X > t:
        low = t + 1
    t = (low + high) // 2
    X = 0
    Y = 0

### FIXED CODE ###

import math
n, a, b = map(int, input().split())
d = []
for i in range(n):
    d.append(input())
# [d1, d2, d3, ..., dN]
h = [int(m) for m in d]#int型に直す
#print(x)

low = 0
high = math.ceil(max(h)/b)
# t は中央番目の数
t = (low + high) // 2

# 探索の下限のlowが上限のhighになるまで探索
# lowがhighに達すると数は見つからなかっTrueたということ
X = 0
Y = 0
s = 0
while high - low >= 0:
    for j in range(n):
        X += max(0, math.ceil((h[j] - t * b) / (a - b)))
        #Y += max(0, math.ceil((h[j] - (t - 1) * b) / (a - b)))
    if X == t:
        print(t)
        exit()
    elif X < t:
        high = t - 1
        """for j in range(n):
            Y += max(0, math.ceil((h[j] - (t - 1) * b) / (a - b)))"""
    elif X > t:
        low = t + 1
    s = t
    t = (low + high) // 2
    X = 0
    Y = 0
for j in range(n):
  if math.ceil((h[j] - s * b) / (a - b)) > 0:
            Y += math.ceil((h[j] - s * b) / (a - b))
if Y <= s:
  print(s)
else:
  print(s + 1)