Harryxun/stf_run huggingface dataset:
n, a, b = map(int, input().split())

if a == 0:
  print(0)
else:
  x = n % (a + b)
  y = n // (a + b)
  
ans = a * y + min(x, a)
print(ans)

### FIXED CODE ###

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

x = n % (a + b)
y = n // (a + b) 
ans = a * y + min(x, a)
print(ans)
N,Y = map(int, input().split())
c = [-1,-1,-1]
for i in range(N+1):
    for j in range(N+1):
        if N-i-k >= 0 and 10000*i + 5000*j + 1000*(N-i-k) == Y:
            c = [i,j,N-i-k]
            break

print(c[0],c[1],c[2])

### FIXED CODE ###

N,Y = map(int, input().split())
c = [-1,-1,-1]
for i in range(N+1):
    for j in range(N+1):
        a = N - i - j
        if a >= 0 and (10000*i + 5000*j + 1000*a) == Y:
            c = [i,j,a]
            break
print(c[0],c[1],c[2])
n = int(input())
x = input()

l = 2*10**5 + 5
A = [0] * l
for i in range(1,l):
    ab = format(i, "b")
    abo = ab.count("1")
    A[i] = i % abo

B = [-1] * l
B[0] = 0
# print(A[:10])

def dd(y):
    # print(y)
    if B[y] == -1:
        return dd(A[y])+1
    else:
        return B[y]

for i in range(1, l):
    # print(dd(i))
    B[i] = dd(i)

# print(B[:10000])

m = x.count("1")
m0 = m-1
m1 = m+1
M0 = [1]
M1 = [1]
for i in range(l):
    M0.append((M0[-1]*2) % m0)
    M1.append((M1[-1]*2) % m1)

n0 = 0
n1 = 0
for i in range(n):
    if x[n-1-i] == "1":
        n0 = (n0 + M0[i]) % m0
        n1 = (n1 + M1[i]) % m1

for i in range(n):
    nn = 0
    if x[i] == "1":
        nn = (n0 - M0[n-i-1]) % m0
    else:
        nn = (n1 + M1[n-i-1]) % m1
    print(B[nn]+1)



### FIXED CODE ###

n = int(input())
x = input()

# n = 3
# x = "100"

l = 2*10**5 + 5
A = [0] * l
for i in range(1,l):
    ab = format(i, "b")
    abo = ab.count("1")
    A[i] = i % abo

B = [-1] * l
B[0] = 0
# print(A[:10])

def dd(y):
    # print(y)
    if B[y] == -1:
        return dd(A[y])+1
    else:
        return B[y]

for i in range(1, l):
    # print(dd(i))
    B[i] = dd(i)

# print(B[:100])

m = x.count("1")
m0 = m-1
m00 = m0
if m0 == 0:
    m0 = 1

m1 = m+1
M0 = [1]
M1 = [1]
for i in range(l):
    M0.append((M0[-1]*2) % m0)
    M1.append((M1[-1]*2) % m1)

n0 = 0
n1 = 0
for i in range(n):
    if x[n-1-i] == "1":
        n0 = (n0 + M0[i]) % m0
        n1 = (n1 + M1[i]) % m1

for i in range(n):
    nn = 0
    if x[i] == "1":
        nn = (n0 - M0[n-i-1]) % m0
    else:
        nn = (n1 + M1[n-i-1]) % m1
    print(B[nn]+1 if (m00!=0 or x[i]!="1") else 0)
x = map(int, input().split(' '))
print(int(x[0]+x[1]/2))

### FIXED CODE ###

x = list(map(int, input().split(' ')))
print(int(x[0]+x[1]/2))
N=int(input())
H=list(map(int,input().split()))
ans=0
for i in range(1,N):
    if H[i]>=H[1:i-1]:
        ans+=1
print(ans+1)

### FIXED CODE ###

N=int(input())
H=list(map(int,input().split()))
ans=0
for i in range(1,N):
    maxa=max(H[j] for j in range(i))
    if H[i]>=maxa:
        ans+=1
print(ans+1)
n=int(input())
s=input()
cnt=0
a=[]
b=[]
for i in range(n):
  d=s[i]+s[j]
  if d in b:continue
  else:b.append(d)
  for j in range(i+1,n):
    for k in range(j+1,n):
      c=s[i]+s[j]+s[k]
      if c not in a:
        a.append(c)
        cnt+=1
print(cnt)

### FIXED CODE ###

n=int(input())
s=input()
cnt=0
for m in range(1000):
  m=str(m).zfill(3)
  j=0
  for i in m:
    if i not in s[j:]:break
    j+=s[j:].index(i)+1
  else:cnt+=1
print(cnt)
while True:                                                                  
       (a, op, b) = input().split()
       a = int(a)
       b = int(b)
       
       if op = '?':
             break
       elif op = '+':
                print(a + b)
       elif op = '-':
                print(a - b)
       elif op = '*':
                print(a * b)
       elif op = '/':
                print(a // b)

### FIXED CODE ###

while True:
    (a, op, b) = input().split()
    a = int(a)
    b = int(b)

    if op == '?':
        break
    elif op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
n,m,l = [int(x) for x in raw_input().split()]

A = []
for idx in range(0,n):
    A.append([int(x) for x in raw_input().split()])

B = []
for idx in range(0,m):
    B.append([int(x) for x in raw_input().split()])

for line in range(0, n):
    result_list = []
    for idx1 in range(0, l):
        sum = 0
        for idx2 in range(0, m):
            sum += A[line][idx2] * B[idx2][idx1]
        result_list.append(sum)
    
    result_str = ""
    for result in result_list:
        result_str += str(result) + " "
    print result_str

### FIXED CODE ###

n,m,l = [int(x) for x in raw_input().split()]

A = []
for idx in range(0,n):
    A.append([int(x) for x in raw_input().split()])

B = []
for idx in range(0,m):
    B.append([int(x) for x in raw_input().split()])

for line in range(0, n):
    result_list = []
    for idx1 in range(0, l):
        sum = 0
        for idx2 in range(0, m):
            sum += A[line][idx2] * B[idx2][idx1]
        result_list.append(sum)
    
    result_str = ""
    for result in result_list:
        result_str += str(result) + " "
    print result_str.rstrip()
A,B,C = map(int, input().split())
print('YES' if A[-1] == B[0] and B[-1] == C[0] and C[-1] == A[0] else 'NO')

### FIXED CODE ###

A,B,C = input().split()
print('YES' if A[-1] == B[0] and B[-1] == C[0] else 'NO')
N, K = map(int, input().split())
h = []
[h.append(int(input())) for i in range(N)]

l = []
for i in range(N):
    a = []
    for j in range(N):
        if i != j and h[i]-h[j]>=0:
            a.append(h[i]-h[j])
    if len(a) >= K-1:
        l.append(a)

l2 = []
for i in range(len(l)):
    a = min(l[i])
    l[i].remove(a)
    l2.append(min(l[i]))
print(min(l2))


### FIXED CODE ###

N, K = map(int, input().split())
h = []
[h.append(int(input())) for i in range(N)]

h.sort()
l = []
for i in range(N-K+1):
    l.append(h[i+K-1] - h[i])
print(min(l))
N,M=map(int,input().split())
import collections
e =[]
for i in range(N):
    ta,tb =map(int,input().split())
    e.extend([ta,tb])
c = collections.Counter(e)
#print(c)
ans = "YES"
for i in c:
    if c[i]%2 != 0:
        ans = "NO"
print(ans)


### FIXED CODE ###

N,M=map(int,input().split())
import collections
e =[]
for i in range(M):
    ta,tb =map(int,input().split())
    e.extend([ta,tb])
c = collections.Counter(e)
#print(c)
ans = "YES"
for i in c:
    if c[i]%2 != 0:
        ans = "NO"
print(ans)
N = int(input())
A = int(input())
B = int(input())

if N == 1:
    print('Hello World')
elif N == 2:
    print(A+B)

### FIXED CODE ###

N = int(input())


if N == 1:
    print('Hello World')
elif N == 2:
    A = int(input())
    B = int(input())
    print(A+B)
import sys

i = 0
for l in sys.stdin():
  print(l[i], end='')
  i += 1
  

### FIXED CODE ###

import sys

i = 0
for l in sys.stdin:
    print(l[i], end='')
    i += 1

print('')
import math
def calc_pattern(stairs):
    if stairs<=4:
        return stairs
    d=stairs//2+1
    l=[(math.factorial(i+(stairs-i*2))/math.factorial(i)/math.factorial(stairs-i*2))%1000000007  for i in range(d)]
    return (sum(l))%1000000007
"""
for stairs in range(1,11):
    print(stairs, calc_pattern(stairs))
"""
N,M=map(int,input().split())
A=[-1]
A.extend([int(input()) for m in range(M)])
A.append(N+1)
#print(A)
s=1
for m in range(M+1):
    if A[m+1]==1 or A[m]==N-1:
        continue
    if A[m]+1==A[m+1]:
        print(0)
        exit()
    else:
        #print("{} ~ {}".format(A[m]+1, A[m+1]-1))
        #print(calc_pattern(A[m+1]-1 - (A[m]+1)))
        s*=calc_pattern(A[m+1]-1 - (A[m]+1))
        s%=1000000007
        #print(s)
print(int(s))
# 0~A[0]-1, A[0]+1~A[1]-1
# A の先頭に-1を入れれば、A[i]+1~A[i+1]-1 で統一できそう


### FIXED CODE ###

N,M=map(int,input().split())
A=[int(input()) for n in range(M)]
S=[1]*(N+1)
for a in A:
  S[a]=0
for i in range(2,N+1):
  S[i]=(S[i-1]+S[i-2])%1000000007*S[i]

print(S[-1])
import sys
input = sys.stdin.readline
s = input()
n = len(s)
ans = 0
for i in range(1<<(n-1)):
    t = ''
    for j in range(n-1):
        t += s[j]
        if (i >> j) & 1:
            t += '+'
    else:
        t += s[n-1]
    ans += eval(t)
print(ans)


### FIXED CODE ###

import sys
input = sys.stdin.readline
s = input().strip()
n = len(s)
ans = 0
for i in range(1<<(n-1)):
    t = ''
    for j in range(n-1):
        t += s[j]
        if (i >> j) & 1:
            t += '+'
    else:
        t += s[n-1]
    ans += eval(t)
print(ans)
# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
A.sort()
# cnts = Counter(A)
cnts = {}
for i in range(N):
    if A[i] not in cnts.keys():
        cnts[A[i]] = 1
    else:
        cnts[A[i]] += 1
d = {}
for k in cnts.keys():
    if cnts[k] >= 2:
        d[k] = cnts[k] // 2 
ids = list(d.keys())[::-1]
if d[ids[0]] >= 2:
    ans = ids[0] ** 2
elif len(ids) >= 2:
    ans = ids[0] * ids[1]
else:
    ans = 0
print(ans)

### FIXED CODE ###

# coding: utf-8
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
Aset = list(set(A))
Aset.sort(reverse=True)
a, b = 0, 0
L = []
cnt = 1
for i in range(1, N):
    if A[i] == A[i-1]:
        cnt += 1
    else:
        L.append(cnt)
        cnt = 1
if A[-1] == A[-2]:
    L.append(cnt)
idx = 0
for i in range(len(L)):
    if L[i] >= 4:
        a, b = Aset[i], Aset[i]
        break
    elif L[i] >= 2:
        a = Aset[i]
        idx = i + 1
        break
if b <= 0:
    for i in range(idx, len(L)):
        if L[i] >= 2:
            b = Aset[i]
            break
print(a * b)
n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]

S=set(s)
L=len(S)
a=[0]*(L+1)
for i in L:
    a[i]=s.count(S[i])-t.count(S[i])
print(max(a))

### FIXED CODE ###

n=int(input())
s=[input() for i in range(n)]
m=int(input())
t=[input() for i in range(m)]

S=set(s[i] for i in range(n))
L=len(S)
x = list(S)
a=[0]*(L+1)
for i in range(L):
    a[i]=s.count(x[i])-t.count(x[i])
print(max(a))
n = int(input())
a=list(map(int,input().split()))

if n%2==0:
	ans=1
	for i in range(n/2):
		ans=ans*a[i]*a[i+n/2]
else:
	if n==1:
		ans=a[0]
	else:
		ans=a[0]
		for i in range(1,int((n-1)/2)+1):
			ans=ans*a[i]*a[i+int((n-1)/2)]

if ans>1000000000000000000:
	print("-1")
else:
	print(ans)

### FIXED CODE ###

import sys

def main():
    n = int(input())
    a=sys.stdin.readline().rstrip().split()
    if '0' in a:
        print(0)
        return
    ans=1
 
    for i in a:
        ans=ans*int(i)
        if ans>1000000000000000000:
            print("-1")
            return
    else:
        print(ans)
main()
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    if n in (1,3):
        raise Exception
    else:
        print("No")
if __name__ == '__main__':
    main()

### FIXED CODE ###

#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N = I()
    N*=2
    size = -1
    group_num = -1
    for i in range(2,N+2):
        if i*(i-1)==N:
            group_num = i
            size = i-1
            break
    if size == -1:
        print("No")
        return 
    
    ans = [[-1]*size for _ in range(group_num)]

    now = 0
    for i in range(group_num):
        for j in range(size):
            if j<i:
                ans[i][j] = ans[j][i-1]
            else:
                now += 1
                ans[i][j] = now

        
    print("Yes")
    print(group_num)
    for a in ans:
        print(size,*a)

if __name__ == '__main__':
    main()
#!/usr/bin/env python3
import sys
import string

l = [None]+[c for c in string.ascii_lowercase]
def f(N: int):
    if N // 26:
        return f(N//26) + l[N%26]
    else:
        return l[N%26]

def solve(N):
    print(f(N))

# Generated by 1.1.7.1 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()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys
import string

l = [c for c in string.ascii_lowercase]
def f(N: int):
    N -= 1
    if N // 26:
        return f(N//26) + l[N%26]
    else:
        return l[N%26]

def solve(N):
    print(f(N))

# Generated by 1.1.7.1 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()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()
def dfs(p,v,c):
    ans[v]=c
    for i in E[v]:
        if i[0]==p:
            continue
        if i[1]%2==1:
            dfs(v,i[0],1-c)
        else:
            dfs(v,i[0],c)
N= int(input())
ans = [100]*(N+1)
memo = {i:False for i in range(1,N+1)}
E = {i: []for i in range(1,N+1)}
for i in range(N-1):
    u,v,w = list(map(int,input().split()))
    E[v].append((u,w))
    E[u].append([v,w])
dfs(-1,1,1)
for i in range(1,N+1):
    print(ans[i])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**7)
def dfs(p,v,c):
    ans[v]=c
    for i in E[v]:
        if i[0]==p:
            continue
        if i[1]%2==1:
            dfs(v,i[0],1-c)
        else:
            dfs(v,i[0],c)
N= int(input())
ans = [100]*(N+1)
memo = {i:False for i in range(1,N+1)}
E = {i: []for i in range(1,N+1)}
for i in range(N-1):
    u,v,w = list(map(int,input().split()))
    E[v].append((u,w))
    E[u].append([v,w])
dfs(-1,1,1)
for i in range(1,N+1):
    print(ans[i])
n,m=map(int,input().split())
x=9999999999999999
s=[list(map(int,input().split())) for i in range(m)]
s=sorted(s)
for i in range(m):
  if s[i][0]==1 and s[i][1]==0:
    x=-1

for i in range(m):
  for j in range(m):
    if s[i][0]==s[j][0] and s[i][1]!=s[j][1]:
      x=-1

a=[0]*n
ans=0
for i in range(n):
  a[s[i][0]-1]=s[i][1]

if a[0]==0:
  a[0]=1

for i in range(m):
  ans+=a[i]*10**(n-i-1)


print(min(x,ans))

### FIXED CODE ###

n,m=map(int,input().split())
x=99999
s=[list(map(int,input().split())) for i in range(m)]
s=sorted(s)
for i in range(m):
    if s[i][0]==1 and s[i][1]==0 and n!=1:
        x=-1

for i in range(m):
    for j in range(m):
        if s[i][0]==s[j][0] and s[i][1]!=s[j][1]:
            x=-1

a=[0]*n
ans=0
for i in range(m):
    a[s[i][0]-1]=s[i][1]

if a[0]==0 and n!=1:
    a[0]=1

for i in range(n):
    ans+=a[i]*(10**(n-i-1))


print(min(x,ans))
n, x, t = int(input()).split(" ")
print((n//x+1)*t)

### FIXED CODE ###

n, x, t = map(int, input().split())
if n % x == 0:
  print(int(n/x*t))
else:
  print(int((n//x+1)*t))
s = input()
q = int(input())
r = False#ひっくり返されたか
for i in range(q):
  t=list(input().split())
  if len(t) == 1:#一つしか入力されていない
    r = not(r)
  else:
    if t[1] == '1' and r = False
      s = t[2] + s
    elif t[1] == '2' and r = True:
      s = t[2] + s
    else:
      s = s + t[2]
print(s)

### FIXED CODE ###

s = input()
q = int(input())
r = False#ひっくり返されたか
f = ''#in front of#逆転しているので最後に戻しましょう
b = '' #behind
for i in range(q):
  t=list(input().split())
  if len(t) == 1:#一つしか入力されていない
    r = not(r)
  else:
    if (t[1] == '1' and r == False):
      f += t[2]
    elif (t[1] == '2' and r == True):
      f += t[2]
    else:
      b += t[2]
s = f[::-1] + s + b
if r:
  print(s[::-1])
else:
  print(s)
S=int(input())
num=0
for i in range(len(S)//2):
  if S[i]!=S[-i]:
    num+=1
print(num)
  

### FIXED CODE ###

S=input()
num=0
for i in range(len(S)//2):
  if S[i]!=S[-(i+1)]:
    num+=1
print(num)
x,a,b = map(int, input().split())
print((x-a)%b)

### FIXED CODE ###

x = int(input())
a = int(input())
b = int(input())
if x-a==0:
   print(0)
else:
   print((x-a)%b)
n = int(input())
S = [input() for _ in range(n)]

count = 0
ba = 0
wa = 0
bw = 0
for s in S:
    count += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        ba += 1
    elif s[0] == 'B':
        bw += 1
    elif s[-1] == 'A':
        wa += 1

if ba:
    count += ba - 1
    ba = 1
if ba:
    if wa and bw:
        count += 2
        wa -= 1
        bw -= 1
        ba -= 1
    if ba:
        if wa < bw:
            wa += 1
        else:
            bw += 1
count += min(wa,bw)

print(count)´

### FIXED CODE ###

n = int(input())
S = [input() for _ in range(n)]

count = 0
ba = 0
wa = 0
bw = 0
for s in S:
    count += s.count('AB')
    if s[0] == 'B' and s[-1] == 'A':
        ba += 1
    elif s[0] == 'B':
        bw += 1
    elif s[-1] == 'A':
        wa += 1

if ba:
    count += ba - 1
    ba = 1
if ba:
    if wa and bw:
        count += 2
        wa -= 1
        bw -= 1
        ba -= 1
    if ba:
        if wa < bw:
            wa += 1
        else:
            bw += 1
count += min(wa,bw)

print(count)
'''input
1 1
#
'''
# A coding delight
from sys import stdin, stdout
import gc
gc.disable()
input = stdin.readline
from collections import deque


def mp(arr):
	return str(arr[0]) + ' ' + str(arr[1])

def bfs(source, target):
	myq = deque()
	myq.append(mp(source))
	visited = dict()
	visited[mp(source)] = True
	dist = 0
	while len(myq) > 0:
		temp = deque()
		while len(myq) > 0:
			x, y  = list(map(int, myq.popleft().split()))
			if mp([x,y]) == mp(target):
				return dist
			if x - 1 >= 0 and maze[x - 1][y] != '#' and mp([x - 1, y]) not in visited:
				visited[mp([x -1, y])] = True
				temp.append(mp([x - 1, y]))
			if x  + 1 < n and maze[x + 1][y] != '#' and mp([x + 1, y]) not in visited:
				visited[mp([x + 1, y])] = True
				temp.append(mp([x + 1, y]))
			if y - 1 >= 0 and maze[x][y - 1] != '#' and mp([x, y - 1]) not in visited:
				visited[mp([x, y - 1])] = True
				temp.append(mp([x, y - 1]))
			if y + 1 < m and maze[x][y + 1] != '#' and mp([x, y + 1]) not in visited:
				visited[mp([x, y + 1])] = True
				temp.append(mp([x, y + 1]))
		dist += 1
		myq = temp
	return -float('inf')			


# main starts
n, m = list(map(int, input().split()))
maze = []
for _ in range(m):
	state = list(stdin.readline().strip())
	maze.append(state)

ans = -float('inf')
for i in range(n):
	for j in range(m):
		for x in range(n):
			for y in range(m):
				first = [i, j]
				second = [x, y]
				ans = max(ans, bfs(first, second))
print(ans)


### FIXED CODE ###

'''input
3 3
.#.
#..
.#.
'''
# A coding delight
from sys import stdin, stdout
import gc
gc.disable()
input = stdin.readline
from collections import deque


def mp(arr):
	arr = map(str, arr)
	return ' '.join(arr)


def bfs(source):
	myq = deque()
	myq.append(source)
	visited = dict()
	visited[mp(source)] = True
	dist = -1
	while len(myq) > 0:
		temp = deque()
		dist += 1
		while len(myq) > 0:
			x, y  = myq.popleft()
			if x - 1 >= 0:
				if maze[x - 1][y] != '#' and mp([x - 1, y]) not in visited:
					visited[mp([x -1, y])] = True
					temp.append([x - 1, y])
			if x + 1 < n:
				if maze[x + 1][y] != '#' and mp([x + 1, y]) not in visited:
					visited[mp([x + 1, y])] = True
					temp.append([x + 1, y])
			if y - 1 >= 0:
				if maze[x][y - 1] != '#' and mp([x, y - 1]) not in visited:
					visited[mp([x, y - 1])] = True
					temp.append([x, y - 1])
			if y + 1 < m:
				if maze[x][y + 1] != '#' and mp([x, y + 1]) not in visited:
					visited[mp([x, y + 1])] = True
					temp.append([x, y + 1])
		myq = temp
	return dist		


# main starts
n, m = list(map(int, input().split()))
maze = []
for _ in range(n):
	state = list(input().strip())
	maze.append(state)

# from random import randint
# for _ in range(1000):
# maze = []
# n = randint(1, 20)
# m = randint(1, 20)
# for i in range(n):
# 	temp = []
# 	for j in range(m):
# 		k = randint(1, 2)
# 		if k == 1:
# 			temp.append('.')
# 		else:
# 			temp.append('#')
# 	maze.append(temp)

ans = 0
for i in range(n):
	for j in range(m):
		if maze[i][j] != '#':
			first = [i, j]
			ans = max(ans, bfs(first))
print(ans)
import numpy as np
n,k=map(int, input().split())
exp=list(map(lambda x:(int(x)+1)/2,input().split())) # 入力と同時に期待値計算

l=np.cumsum(exp) # 累積和の計算

ans=l[k-1]
for i in range(n-k):
    ans=max(ans,l[i+k]-l[i])
    
print(ans)

### FIXED CODE ###

import numpy as np
n,k=map(int, input().split())
exp=list(map(lambda x:(int(x)+1)/2,input().split())) # 入力と同時に期待値計算

l=np.cumsum(exp) # 累積和の計算

ans=l[k-1]
for i in range(n-k):
    ans=max(ans,l[i+k]-l[i])
    
print(ans)
def main(n, a):
    ans = 0

    for i in a:
        ans += i - 1

    print(ans)


if __name__ == "__main__":
    n = int(input())
    a = lis(map(int, input().split()))

    main(n, a)


### FIXED CODE ###

def main(n, a):
    ans = 0

    for i in a:
        ans += i - 1

    print(ans)


if __name__ == "__main__":
    n = int(input())
    a = list(map(int, input().split()))

    main(n, a)
def main():
  [a, t, k] = [int(i) for i in input().split()]
  if a + t >= k:
    a = 0
    t = 0
  elif a >= k:
    a = 0
    t = t - (k -a)
  else:
    a = a - k:

if __name__ == "__main__":
  main()
  

### FIXED CODE ###

def main():
  [a, t, k] = [int(i) for i in input().split()]
  if a + t <= k:
    a = 0
    t = 0
  elif a <= k:
    t = t - (k - a)
    a = 0
  else:
    a = a - k
  print(a, t)

if __name__ == "__main__":
  main()
a[]=input()
count = 0
fot i in range(3)
	if a[i] = 1:
  		count = count + 1
print(count)

### FIXED CODE ###

a = str(input())
count = 0
for i in range(3):
  if int(a[i]) == 1:
    count = count + 1
print(count)
import math
a, b = map(double, input().split())
c = int(math.floor(a * b))
print(c)

### FIXED CODE ###

a,b = map(int, input().split())
c = a * b
print(c)
A,B=[int(e) for r in input().split(' ')]
print(max([A+B,A-B,A*B]))

### FIXED CODE ###

A,B=[int(e) for e in input().split(' ')]
print(max([A+B,A-B,A*B]))
n = int(input())
ans(n*(n-1)//2)

### FIXED CODE ###

n = int(input())
print(n*(n-1)//2)
n,k=map(int,input().split())
mon=list(map(int,input().split()))
mon.sort(reverse=True)

print(sum(mon[k:]))


### FIXED CODE ###

h,a=map(int,input().split())
ans=h//a+1
if h%a==0:
  ans-=1
print(ans)