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

n, a, b = map(int, input().split())
pre_h = [int(input()) for _ in range(n)]

minimum = (min(pre_h) - 1) // a + 1

h = [0] * n
while True:
	for i in range(n):
		if pre_h[i] - b * minimum > 0:
			h[i] = pre_h[i] - b * minimum
		else:
			h[i] = 0

	if sum([(i - 1) // (a - b) + 1 for i in h]) <= minimum:
		break

	#print(h)
	minimum += 1

print(minimum)

### FIXED CODE ###

n, a, b = map(int, input().split())
pre_h = [int(input()) for _ in range(n)]

def check(cnt):
	h = [0] * n
	for i in range(n):
		if pre_h[i] - b * cnt > 0:
			h[i] = pre_h[i] - b * cnt
		else:
			h[i] = 0

	if sum([(i - 1) // (a - b) + 1 for i in h]) <= cnt:
		return True
	else:
		return False

minimum = 1
maximum = (max(pre_h) - 1) // b + 1

while maximum - minimum > 1:
	if check(minimum + (maximum - minimum) // 2):
		maximum = minimum + (maximum - minimum) // 2
	else:
		minimum = minimum + (maximum - minimum) // 2

print(maximum)
### BUGGY CODE ###

n=int(input())
a=[]
for i in range(n):
    s=input()
    s=sorted(s)
    a.append("".join(s))
ans=0
for i in range(len(a)):
    for j in range(i+1,len(a)):
        if a[i]==a[j]:
            ans+=1
print(ans)

### FIXED CODE ###

n=int(input())
a=set()
b=[]
import collections
for i in range(n):
    s=input()
    s=sorted(s)
    a.add("".join(s))
    b.append("".join(s))
ans=0
a=list(a)
c=collections.Counter(b)
for i in range(len(a)):
    ans+=c[a[i]]*(c[a[i]]-1)//2
print(ans)
### BUGGY CODE ###

from collections import deque


def inside(x, l, r):
    return l <= x < r


H, W = map(int, input().split())
A = [list(input()) for i in range(H)]
qu = deque()

rest = H * W
for i in range(H):
    for j in range(W):
        if A[i][j] == '#':
            rest -= 1
            qu.append((i, j))

ans = 0
dx = [0, 1, 0, -1]
dy = [1, 0, -1, 0]
while True:
    if rest == 0:
        break
    ans += 1
    qu2 = deque()
    while qu:
        i0, j0 = qu.popleft()
        for k in range(4):
            ni = i0 + dx[k]
            nj = j0 + dy[k]
            if not (inside(ni, 0, H) and inside(nj, 0, W)):
                continue
            if A[ni][nj] == '.':
                A[ni][nj] = '#'
                rest -= 1
                qu2.append((ni, nj))
    qu = qu2
print(ans)



### FIXED CODE ###

# 参考

import numpy

H, W = map(int, input().split())
values = [None] * H

for y in range(H):
    values[y] = [0 if v == "#" else H + W for v in input()]
values = numpy.array(values)

for x in range(W - 1):
    values[:, x + 1] = numpy.minimum(values[:, x] + 1, values[:, x + 1])

for x in range(W - 1, 0, -1):
    values[:, x - 1] = numpy.minimum(values[:, x] + 1, values[:, x - 1])

for y in range(H - 1):
    values[y + 1, :] = numpy.minimum(values[y, :] + 1, values[y + 1, :])

for y in range(H - 1, 0, -1):
    values[y - 1, :] = numpy.minimum(values[y, :] + 1, values[y - 1, :])

print(numpy.max(values))
### BUGGY CODE ###

n, m = map(int, input().split())
x = list(map(int, input().split()))
l = []
if n >= m:
    print(0)
    exit()
else:
    x.sort()
    for i in range(m - 1):
        l.append(x[i + 1] - x[i])
    for j in range(n - 1):
        l.remove(max(l))
    print(sum(l))

### FIXED CODE ###

n, m = map(int, input().split())
x = list(map(int, input().split()))
l = []
if n >= m:
    print(0)
else:
    x = set(x)
    x = list(x)
    x.sort()
    for i in range(m - 1):
        l.append(x[i + 1] - x[i])
    l.sort()
    l.reverse()
    del l[0:n - 1]
    print(sum(l))
### BUGGY CODE ###

import math
import copy
from copy import deepcopy
import sys
import fractions
import numpy as np
from functools import reduce
import statistics
import heapq

# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

def getInputStr():
    inputStr = str(input())
    return inputStr

data = getInputStr()

a = str(data)
listStr = []
listStr = list(a)

# del listStr[len(listStr)-1]
listStr.reverse()

dp = [[0]*13 for _ in range(len(listStr)+1)]
dp[0][0] = 1

INF = 10 ** 9 + 7

for i in range(len(listStr)):
    keta = pow(10, i) % 13


    if listStr[i] == "?":
        for k in range(10):
            for j in range(13):
                dp[i+1][int(((k*keta)%13 + j) % 13)] += dp[i][j]
                # dp[i+1][int(((k*keta)%13 + j) % 13)] += dp[i][j]
    else:
        k = int(listStr[i])
        for j in range(13):
            dp[i + 1][int(((k * keta) % 13 + j) % 13)] += dp[i][j]

ans = dp[len(listStr)][5] % INF
print(ans)

### FIXED CODE ###

import sys
import re
import math
import collections
import bisect
import itertools
import fractions
import functools
import copy
import heapq
import decimal
import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10 ** 9)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))
nb = lambda: list(map(lambda x: int(x) - 1, sys.stdin.readline().split()))


# ===CODE===


def main():
    s = list(input())
    l = len(s)
    dp = [[0 for _ in range(13)] for __ in range(l + 1)]
    dp[0][0] = 1

    for i, si in enumerate(s):
        base = pow(10, l - i - 1, 13)

        if si == "?":
            for k in range(10):
                tmp = base * k % 13
                for j in range(13):
                    dp[i + 1][(j + tmp) % 13] += dp[i][j]
                    dp[i + 1][(j + tmp) % 13] %= MOD
        else:
            si = int(si)
            tmp = base * si % 13
            for j in range(13):
                dp[i + 1][(j + tmp) % 13] += dp[i][j]
                dp[i + 1][(j + tmp) % 13] %= MOD

    print(dp[l][5])


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

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

if __name__ == '__main__':
    N = int(input())
    S = input()

    r = N
    for i in range(len(S)):
        t = S[:i].count("W") + S[i+1:].count("E")
        r = min(r, t)
    print(r)

### FIXED CODE ###

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

if __name__ == '__main__':
    N = int(input())
    S = input()

    wn = [0]
    en = [0]

    for i in range(N):
        if S[i] == "W":
            wn.append(wn[-1]+1)
            en.append(en[-1])
        if S[i] == "E":
            wn.append(wn[-1])
            en.append(en[-1]+1)

    m = N
    for i in range(len(S)):
        t = (wn[i] - wn[0]) + (en[N] - en[i+1])
        m = min(m, t)

    print(m)
### BUGGY CODE ###

from collections import deque

N, M, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# print(N, M, K)
# print(A)
# print(B)


answer = 0
consumption_A = 0
for i in range(len(A) + 1):
    consumption_A += A[i - 1] if i >= 1 else 0
    if (consumption_A > K): break

    consumption_B = 0
    for j in range(len(B) + 1):
        consumption_B += B[j - 1] if j >= 1 else 0
        consumption = consumption_A + consumption_B
        if (consumption > K): break
    
        num_books = i + j
        answer = max(answer, num_books)

print(answer)


### FIXED CODE ###

from collections import deque

N, M, K = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))
# print(N, M, K)
# print(A)
# print(B)


consumptions_A = [0]
for i in range(len(A)):
    consumptions_A.append(consumptions_A[i] + A[i])

consumptions_B = [0]
for i in range(len(B)):
    consumptions_B.append(consumptions_B[i] + B[i])

answer = 0
j = M
for i in range(len(consumptions_A)):
    if (consumptions_A[i] > K): break

    remaining_time = K - consumptions_A[i]
    while consumptions_B[j] > remaining_time:
        j -= 1
    
    num_books = i + j
    answer = max(answer, num_books)

print(answer)
### BUGGY CODE ###

#かいせつ

import itertools

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

lr = [[0 for i in range(n)] for j in range(n)]
for _ in range(m):
    l,r = map(int,input().split())
    lr[l-1][r-1] += 1

acc_lr = []
for l in lr:
    acc_lr.append([0] + list(itertools.accumulate(l)))

for _ in range(q):
    l,r = map(int,input().split())
    ans = 0
    for ls in acc_lr[l-1:r]:
        ans += ls[r] - ls[l-1]
        #print(ls,r,l-1)
    print(ans)


### FIXED CODE ###

import itertools

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

lr = [[0 for i in range(n)] for j in range(n)]
for _ in range(m):
    l,r = map(int,input().split())
    lr[l-1][r-1] += 1

acc_lr = []
for l in lr:
    acc_lr.append([0] + list(itertools.accumulate(l)))

for _ in range(q):
    l,r = map(int,input().split())
    ans = 0
    for ls in acc_lr[l-1:r]:
        ans += ls[r] - ls[l-1]
    print(ans)
### BUGGY CODE ###

N,K = map(int,input().split())
h = [0] + list(map(int,input().split()))

dp = [None for _ in range(N+1)]
dp[1] = 0

for i in range(2,N+1):
    if i < K+1:
        scope = i-1
    else:
        scope = K
    jump = [dp[i-x] + abs(h[i]-h[i-x]) for x in range(1,scope+1)]
    dp[i] = min(jump)
    
print(dp[N])

### FIXED CODE ###

import sys
input = sys.stdin.readline
 
N,K = map(int,input().split())
h = [0] + list(map(int,input().split()))
 
dp = [None for _ in range(N+1)]
dp[1] = 0
 
for i in range(2,N+1):
    scope = min(i-1,K)
    jump = [dp[i-x] + abs(h[i]-h[i-x]) for x in range(1,scope+1)]
    dp[i] = min(jump)
    
print(dp[N])
### BUGGY CODE ###

import copy

N = int(input())

a_list = []
for i in range(N):
    a_list.append(int(input()))

for i in range(N):
    tmp_list = copy.copy(a_list)
    tmp_list.pop(i)
    print(max(tmp_list))

### FIXED CODE ###

N = int(input())

a_list = []
for i in range(N):
    a_list.append(int(input()))

max_value = max(a_list)

if a_list.count(max_value) > 1:
  for i in range(N):
    print(max_value)
else:
  for i in range(N):
    if a_list[i] == max_value:
      print(sorted(a_list)[-2])
    else:
      print(max_value)
### BUGGY CODE ###

from functools import lru_cache

N, W = map(int, input().split())
WV = []

for i in range(N):
  w, v = map(int, input().split())
  WV.append((w, v))

@lru_cache(None)
def Knap(i, j):
  ret = 0
  if i == N:
    ret = 0
  elif j < WV[i][0]:
    ret = Knap(i+1, j)
  else:
    ret = max(Knap(i+1, j), Knap(i+1, j-WV[i][0])+WV[i][1] )
  return ret

print(Knap(0, W))

### FIXED CODE ###

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

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(N):
  w, v = map(int, input().split())
  for j in range(W+1):
    if j - w < 0:
      dp[i+1][j] = dp[i][j]
    else:
      dp[i+1][j] = max(dp[i][j], dp[i][j-w] + v)

print(dp[-1][-1])
### BUGGY CODE ###

from collections import defaultdict

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

count_dict = defaultdict(int)
for cal in A:
  count_dict[cal] += 1
    
    
"""
それぞれの要素について、1個減った時とそのままの場合での組み合わせ数を事前に計算しておく
"""
from math import factorial
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))
  
# list[0]=そのまま、list[1]=1個減った場合
count_result = defaultdict(list)
for k,v in count_dict.items():
  if v > 2:
    count_result[k] = [combinations_count(v,2), combinations_count(v-1,2)]
  elif v == 2:
    count_result[k] = [1,0]    
  else:
    count_result[k] = [0,0]


"""
対象の数字を指定した場合の答え、を事前に計算しておく
2*10**5
"""
all_ans = 0
for k,v in count_result.items():
  all_ans += v[0]

"""
前から順に表示していく
2*10**5
"""
for _ in A:
  # 対象の数字
  ans = all_ans - count_result[_][0] + count_result[_][1]
  print(ans)



### FIXED CODE ###

from collections import defaultdict

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

count_dict = defaultdict(int)
for cal in A:
  count_dict[cal] += 1
    
from math import factorial
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

count_result = defaultdict(list)
for k,v in count_dict.items():
  if v > 2:
    count_result[k] = [combinations_count(v,2), combinations_count(v-1,2)]
  elif v == 2:
    count_result[k] = [1,0]    
  else:
    count_result[k] = [0,0]

all_ans = 0
for v in count_result.values():
  all_ans += v[0]


for _ in A:
  ans = all_ans - count_result[_][0] + count_result[_][1]
  print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def func(x, nn):
    value = 0
    for i in range(nn - 1):
        for j in range(i + 1, nn):
            value += x[i] ^ x[j]
    ans = value % (10 ** 9 + 7)
    return ans

def main():
    n = int(input())
    li = tuple(map(int, input().split()))
    print(func(li, n))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import numpy as np
n = int(input())
arr = np.array([int(i) for i in input().split()])
mod = 10 ** 9 + 7
s = 0

for i in range(60):
    t = arr & 1
    c1 = np.count_nonzero((arr & 1))
    s += 2 ** i * c1 * (n - c1)
    arr >>= 1

print(s % mod)
### BUGGY CODE ###

N = int(input())
S = input()

ans = N
for n in range(0, N):
  leader = S[n]
  west_side = [s for s in S[:n] if s == 'W']
  east_side = [s for s in S[n+1:] if s == "E"]
  
  ans = min(ans, (len(west_side) + len(east_side)))
  
print(ans)

### FIXED CODE ###

N=int(input())
S=input()

w_cusum_list = []
w = 0
for i in range(N):
  if S[i] == 'W':
    w += 1
  w_cusum_list.append(w)
    
e_cusum_list = []
e = 0
for i in range(1, N):
  if S[-i] == 'E':
    e += 1
  e_cusum_list.append(e)

minn = min(w_cusum_list[-1], e_cusum_list[-1])
for i in range(1, N):
  sumn = w_cusum_list[i-1] + e_cusum_list[N-i-1]
  if minn > sumn:
    minn = sumn

print(minn)
### BUGGY CODE ###

import sys
input = sys.stdin.buffer.readline

def main():

    N, Q = map(int, input().split())
    C = list(map(lambda x: int(x) - 1, input().split()))

    M = int(N**0.5)
    K = (N + M - 1) // M

    query = []

    for i in range(Q):
        l, r, = map(int, input().split())
        query.append((l - 1, r, i))

    query.sort(key = lambda x: (x[0] // M, x[1]))

    lt, rt = 0, 0
    S = [0 for _ in range(N)]
    tmp = 0
    res = [0 for _ in range(Q)]

    for l, r, i in query:
        while lt > l:
            lt -= 1
            if S[C[lt]] == 0:
                tmp += 1
            S[C[lt]] += 1
        while rt < r:
            if S[C[rt]] == 0:
                tmp += 1
            S[C[rt]] += 1
            rt += 1
        while lt < l:
            if S[C[lt]] == 1:
                tmp -= 1
            S[C[lt]] -= 1
            lt += 1
        while rt > r:
            rt -= 1
            if S[C[rt]] == 1:
                tmp -= 1
            S[C[rt]] -= 1
        res[i] = tmp

    print('\n'.join(map(str, res)))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline

N, Q = map(int, input().split())
C = list(map(lambda x: int(x) - 1, input().split()))

query = []

for i in range(Q):
    l, r, = map(int, input().split())
    query.append((l - 1, r, i))

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

rt = 0
L = [None for _ in range(N)]
res = [0 for _ in range(Q)]
bit = [0 for _ in range(N + 1)]

for l, r, id in query:
    while rt < r:
        if L[C[rt]] is not None:
            idx = L[C[rt]] + 1
            while idx <= N:
                bit[idx] -= 1
                idx += idx & -idx
        L[C[rt]] = rt
        idx = rt + 1
        while idx <= N:
            bit[idx] += 1
            idx += idx & -idx
        rt += 1
    sr = 0
    sl = 0
    idx = r
    while idx:
        sr += bit[idx]
        idx -= idx & -idx
    idx = l
    while idx:
        sl += bit[idx]
        idx -= idx & -idx
    res[id] = sr - sl

print('\n'.join(map(str, res)))
### BUGGY CODE ###

n, m = list(map(int, input().split()))
card = list(map(int, input().split()))
data = []
for i in range(m):
    data.append(list(map(int, input().split())))
data.sort(key=lambda x:x[1])
count = 0
cnt = 0
for i in range(m):
    cnt = 0
    while min(card) < data[m - i - 1][1] and count < n and cnt < data[m - i - 1][0]:
        card[card.index(min(card))] = data[m - i - 1][1]
        count += 1
        cnt += 1
print(sum(card))

### FIXED CODE ###

import bisect
n,m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()

data = [None] * m
for i in range(m):
    data[i] = list(map(int, input().split()))
data.sort(key = lambda x : x[1])
data.reverse()


ans = 0
count = 0
pre_index = 0
#print(data)
#print(a)
#data[][1] = value, data[][0] = card_num
for i in range(m):
    insert_index = bisect.bisect_left(a, data[i][1])
    count = min(data[i][0], insert_index - pre_index)
    for j in range(pre_index, pre_index + count):
        if j >= n:
            break
        a[j] = 0
    ans += count * data[i][1]
    pre_index = pre_index + count
print(ans + sum(a))
### BUGGY CODE ###

from functools import reduce

MOD = 10**9 + 7

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

def llcm(l):
    return reduce(lcm, l)

def main():
    N = int(input())
    A = list(map(int, input().split()))
    l = llcm(A)
    r = 0
    for i in A:
        r = (r + (l // i)) % MOD
    print(r)

main()


### FIXED CODE ###

from functools import reduce


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

def llcm(l):
    return reduce(lcm, l)

def modinv(a, m):
    b, u, v = m, 1, 0
    while b:
        t = a // b
        a, b = b, a - t * b
        u, v = v, u - t * v
    u %= m
    if u < 0:
        u += m
    return u

def main():
    MOD = 10**9 + 7
    N = int(input())
    A = list(map(int, input().split()))
    l = llcm(A) % MOD
    r = 0
    for i, a in enumerate(A):
        r = (r + l * modinv(a, MOD)) % MOD
    return r

print(main())
### BUGGY CODE ###

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

H,W = map(int,input().split())
q = []

visited = [[True]*(W+2)]
visited += [[True] + [x == '#' for x in input().rstrip()] + [True] for _ in range(H)]
visited.append([True]*(W+2))
for i in range(1,H+1):
  for j in range(1,W+1):
    if visited[i][j]:
      q.append((i,j))

ans = -1
while q:
  qq = []
  ans += 1
  for x,y in q:
    if not visited[x-1][y]:
      visited[x-1][y] = True
      qq.append((x-1,y))
    if not visited[x+1][y]:
      visited[x+1][y] = True
      qq.append((x+1,y))
    if not visited[x][y-1]:
      visited[x][y-1] = True
      qq.append((x,y-1))
    if not visited[x][y+1]:
      visited[x][y+1] = True
      qq.append((x,y+1))
  q = qq
  
print(ans)

### FIXED CODE ###

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

H,W = map(int,input().split())
INF = 10**18
q = []

visited = [[True]*(W+2)]
visited += [[True] + [x == '#' for x in input().rstrip()] + [True] for _ in range(H)]
visited.append([True]*(W+2))
for i in range(1,H+1):
  for j in range(1,W+1):
    if visited[i][j]:
      q.append((i,j))

moves = [(0,1),(0,-1),(1,0),(-1,0)] #全方向調べる

ans = -1
while q:
  qq = []
  ans += 1
  for x,y in q:
    if not visited[x-1][y]:
      visited[x-1][y] = True
      qq.append((x-1,y))
    if not visited[x+1][y]:
      visited[x+1][y] = True
      qq.append((x+1,y))
    if not visited[x][y-1]:
      visited[x][y-1] = True
      qq.append((x,y-1))
    if not visited[x][y+1]:
      visited[x][y+1] = True
      qq.append((x,y+1))
  q = qq
  
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
def main():
    N = int(input())
    A = [x for x in input().split()]
    l = [0] * N
    B = set(A)
    C = list(B)
    for i in C:
        l[int(i)-1] = A.count(i)
    for i in range(N):
        print(l[i])
        
main()

### FIXED CODE ###

def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    l = [0]*N
    for i in A:
        l[i-1] += 1
    for j in l:
        print(j)
main()
### BUGGY CODE ###

n=int(input())
dp=list(map(int,input().split()))
m=int(input())
tp=list(map(int,input().split()))
d=dict()

ans="YES"

for di in dp:
    if di in d:
        d[di]+=1
    else:
        d[di]=1

for ti in tp:
    if ti not in dp or d[ti]==0:
        ans="NO"
        break
    else:
        d[ti]-=1
print(ans)

### FIXED CODE ###

import collections
n=int(input())
dp=collections.Counter(int(x) for x in input().split())
m=int(input())
tp=collections.Counter(int(x) for x in input().split())
ans="YES"
for k,v in tp.items():
    if dp[k]<v:
        ans="NO"
        break
print(ans)
### BUGGY CODE ###

H, W = map(int, input().split())
S = [input() for _ in range(H)]

M_W = [[0] * W for i in range(H)]
M_H = [[0] * W for i in range(H)]

for i in range(H):
  for j in range(W):
    if S[i][j] == '.':
      if j == 0:
        M_W[i][j] = 1
      else:
        M_W[i][j] = M_W[i][j - 1] + 1
    else:
      M_W[i][j] = 0

for i in range(H):
  max_num = 0
  for j in range(W - 1, -1, -1):
    if M_W[i][j] != 0:
      max_num = max(max_num, M_W[i][j])
      M_W[i][j] = max_num
    else:
      max_num = 0

for j in range(W):
  for i in range(H):
    if S[i][j] == '.':
      if i == 0:
        M_H[i][j] = 1
      else:
        M_H[i][j] = M_H[i - 1][j] + 1
    else:
      M_H[i][j] = 0

for j in range(W):
  max_num = 0
  for i in range(H - 1, -1, -1):
    if M_H[i][j] != 0:
      max_num = max(max_num, M_H[i][j])
      M_H[i][j] = max_num
    else:
      max_num = 0

ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans, M_W[i][j] + M_H[i][j] -1)
print(ans)


### FIXED CODE ###

H, W = map(int, input().split())
S = [input() for _ in range(H)]

M_W = [[0] * W for i in range(H)]
M_H = [[0] * W for i in range(H)]

for i in range(H):
  for j in range(W):
    if S[i][j] == '.':
      if j == 0:
        M_W[i][j] = 1
      else:
        M_W[i][j] = M_W[i][j - 1] + 1
  for j in range(W-2,-1,-1):
    if S[i][j] == '.' and S[i][j+1] == '.':
      M_W[i][j] = M_W[i][j+1]

for j in range(W):
  for i in range(H):
    if S[i][j] == '.':
      if i == 0:
        M_H[i][j] = 1
      else:
        M_H[i][j] = M_H[i-1][j] + 1
  for i in range(H-2,-1,-1):
    if S[i][j] == '.' and S[i+1][j] == '.':
      M_H[i][j] = M_H[i+1][j]

#print(M_W)
#print(M_H)

ans = 0
for i in range(H):
  for j in range(W):
    ans = max(ans, M_W[i][j]+M_H[i][j]-1)
print(ans)
### BUGGY CODE ###

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

A.sort()
cnt = 0
flag = -1
for i in range(N):
    flag = -1
    for j in range(N):
        if i != (N-j-1):
            if A[i] % A[N-j-1] == 0:
                flag = 0
                break
    if flag == -1:
        cnt += 1

print(cnt)

### FIXED CODE ###

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

a_max = max(A)
B=[0]*(a_max + 1)

for ai in A:
    for multi in range(ai, a_max+1, ai):
        B[multi] += 1

ans = 0
for ai in A:
    if B[ai] == 1:
        ans += 1

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

N,Q=map(int,input().split())
S=input()
L=[tuple(map(int, input().split())) for _ in range(Q)]
print("\n".join([str(len(S[nS-1:nE])-len(S[nS-1:nE].replace("AC", "|"))) for nS, nE in L]))


### FIXED CODE ###

N,Q=map(int,input().split())
S=input()

lis = [0] * len(S)
for i in range(len(S)):

  if i>0:
    lis[i] += lis[i-1]
  if i < len(S)-1 and S[i] == 'A' and S[i+1] == 'C':
    lis[i+1] += 1


for _ in range(Q):
  L = tuple(map(int, input().split()))

  c = 0
  print(lis[L[1]-1]-lis[L[0]-1])