Harryxun/stf_run huggingface dataset:
def inpl(): return [int(i) for i in input().split()]

H, W = inpl()
ans = max(H, W)
S = ''
for _ in range(H):
    S += input()
T = [[0]*(W-1)]
for i in range(H-1):
    t = []
    for j in range(W-1):
        r = S[i*W+j] + S[i*W+j+1] + S[(i+1)*W+j] + S[(i+1)*W+j+1]
        t.append(r.count('.')%2)
    ts = [0]*(W-1)
    for i, k in enumerate(t):
        if k:
            continue
        ts[i] = T[-1][i] + 1
    T.append(ts)
for iT in T[1:]:
    stack = []
    for i, l in enumerate(iT):
        while stack:
            w, h = stack[-1]
            if h > l:
                dw, dh = stack.pop()
                ans = max(ans, (dh+1)*(i-dw+1))
                continue
            break
        stack.append((i, l))
    while stack:
        dw, dh = stack.pop()
        ans = max(ans, (dh+1)*(i-dw+2))
print(ans)

### FIXED CODE ###

from collections import defaultdict
edge = defaultdict(lambda: 0)
def inpl(): return [int(i) for i in input().split()]
N = int(input())
A = inpl()
for i in A:
    edge[i] += 1
doubled = []
for j,k in edge.items():
    if k >= 2:
        doubled.append(j)
    if k >= 4:
        doubled.append(j)
doubled = (sorted(doubled))
if len(doubled) < 2:
    print(0)
else:
    print(doubled[-1]*doubled[-2])
n = input()
if n == Sunny:
  print('Cloudy')
elif n == Cloudy:
  print('Rainy')
else:
  print('Sunny')

### FIXED CODE ###

n = input()
if n == 'Sunny':
  print('Cloudy')
elif n == 'Cloudy':
  print('Rainy')
else:
  print('Sunny')
cos = map(int, intput().split())
res = min(cos)
cos.remove(min(cos))
res += min(cos)
print(res)


### FIXED CODE ###

cos = list(map(int, input().split()))
res = min(cos)
cos.remove(min(cos))
res += min(cos)
print(res)
N,M = map(int,input().split())
edge = []
for i in range(M):
    a,b = map(int,input().split())
    add = []
    for j in range(len(edge)):
        if a in edge[j] or b in edge[j]:
            edge[j].append(a)
            edge[j].append(b)
            add.append(j)
    if len(add) == 0:
        edge.append([a,b])
    elif len(add) >= 2:
        for j in range(1,len(add)):
            edge[add[0]].extend(edge[add[j]])
        for j in range(1,len(add)):
            edge.pop(add[j])
ans = 0
for i in range(len(edge)):
    x = list(set(edge[i]))
    if len(x) > ans:
        ans = len(x)
print(ans)


### FIXED CODE ###

d,t,s = map(int,input().split())
if d <= t*s:
    print("Yes")
else:
    print("No")
n = int(input())
st = map(int, input().split())
flag = True
count = 0

def check(st,count):
    new_list = []
	for i in len(st):
      if i % 2 == 0:
        new_list.append(i)
      else:
        flag = True
        break
    if flag:
      print(count)
      return
    else:
      count += 1
      check(new_list, count)
      

### FIXED CODE ###

def check(st,count):
    flag = False
    new_list = []
    for i in st:
        if i % 2 == 0:
            i = i // 2
            new_list.append(i)
        else:
            flag = True
            break
    if flag:
        print(count)
        return
    else:
      count += 1
      check(new_list, count)

n = int(input())
st = list(map(int, input().split()))
count = 0
check(st, count)
import numpy as np

N = int(input())
b = np.array(list(map(int, input().split())))

v = np.array([1]*N)
A_inv = np.diag(v, k=0)
for n in range(N):
    A_inv += np.diag(((-1)**(n+1))*v[n:], k=-n)
    A_inv += np.diag(((-1)**n)*v[n:], k=n)
x = list(np.dot(A_inv, b))
x = [int(xj) for xj in x]
print(*x)

### FIXED CODE ###

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

S = [0]*(N+1)

for n in range(N):
    S[n+1] = S[n] + ((-1)**n)*b[n]
    
ans = [0]*N
for n in range(N):
    ans[n] = b[n] - ((-1)**n)*S[n] + ((-1)**n)*(S[N]-S[n+1])
    
print(*ans)
N=int(input())
f=[]
for i in range(1,(N+1)//2):
    if N%i==0:
        f.append(min(len(str(i)),len(str(N//i))))
max(f)

### FIXED CODE ###

N=int(input())
ans=float('inf')

for i in range(1,int(N**0.5+1)):
    if N%i==0:
        ans=min(ans,len(str(N//i)))
print(ans)
import numpy as np


def resolve():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))

    A = np.zeros((N, N))
    for i in range(M):
        pp, ss = map(int, input().split())
        ss -= 1
        pp -= 1
        A[pp][ss] = H[ss]
        A[ss][pp] = H[pp]

    ans = 0
    for j in range(N):
        np_max = A[j].max()

        now = H[j]
        if (np_max == 0 or now > np_max):
            ans += 1

    print(ans)


resolve()

### FIXED CODE ###

def resolve():
    n, m = map(int, input().split())
    hhh = list(map(int, input().split()))
    nice = [1] * n

    for _ in range(m):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        ha = hhh[a]
        hb = hhh[b]
        if ha <= hb:
            nice[a] = False
        if ha >= hb:
            nice[b] = False

    print(sum(nice))


resolve()
N = list(int(input()))
answer = "No"
 
for i in range(N):
  if N[i] == 7:
    answer = "Yes"
 
print(answer)

### FIXED CODE ###

N = list((input()))
ans = "No"
 
for i in N:
  if i == "7":
    ans = "Yes"
         
print(ans)
# -*- coding: utf-8 -*-


def main():
    import sys
    input = sys.stdin.readline

    n = input()
    digit = int(n[-1])

    if digit == 3:
        print('bon')
    elif digit == 0:
        print('pon')
    elif digit == 1:
        print('pon')
    elif digit == 6:
        print('pon')
    elif digit == 8:
        print('pon')
    else:
        print('hon')


if __name__ == '__main__':
    main()


### FIXED CODE ###

# -*- coding: utf-8 -*-


def main():
    n = str(input())
    digit = n[-1]

    if digit == '3':
        print('bon')
    elif digit == '0':
        print('pon')
    elif digit == '1':
        print('pon')
    elif digit == '6':
        print('pon')
    elif digit == '8':
        print('pon')
    else:
        print('hon')


if __name__ == '__main__':
    main()
for i in range(9):
    for j in range(9):))
        print('%sx%s=%s' % ((i+1), (j+1), (i+1)*(j+1)

### FIXED CODE ###

# coding: utf-8
# Here your code !
for i in range(9):
    for j in range(9):
        print('%sx%s=%s' % ((i+1), (j+1), (i+1)*(j+1)))
w = input()                
l = list(w)                
l.sort()                   
ans = "Yes"                
for i in range(len(l)):    
    if l[2*i] != l[2*i+1]: 
        ans = "No"         
        break              
print(ans)                 
                           
                           


### FIXED CODE ###

w = input()                    
l = list(w)                    
l.sort()                       
ans = "Yes"                    
if len(l)%2 != 0:
    print("No")
    exit()
for i in range(int(len(l)/2)): 
    if l[2*i] != l[2*i+1]:     
        ans = "No"             
        break                  
print(ans)
n, k = map(int, input().split())
hs = list(map(int, input().split()))
dp=[0]*n
dp[0]=0
for i, hi in enumerate(hs):
    if i == 0:
        continue
    s = max(0, i-k)
    dp[i] = min([ml + abs(hl - hi) for ml, hl in zip(dp[s:i], hs[s:i])])
print(m[-1])

### FIXED CODE ###

n, k = map(int, input().split())
hs = list(map(int, input().split()))
dp=[0]*n
dp[0]=0
for i, hi in enumerate(hs):
    if i == 0:
        continue
    s = max(0, i-k)
    dp[i] = min([ml + abs(hl - hi) for ml, hl in zip(dp[s:i], hs[s:i])])
print(dp[-1])
s = input()
s_list = list(s)
ans = ''
for i in s_list:
  if(s_list[i] != 'B'):
    ans += s_list[i]
  else:
    ans = ans[:-1]
print(ans)

### FIXED CODE ###

str = input()
ans = ''
for i in str:
  if i is '0':
    ans += '0'
  elif i is '1':
    ans += '1'
  elif i is 'B':
    ans = ans[:-1]
print(ans)
N= int(input())
A = list(map(int,input().split()))
A.insert(0,A[0])
A.append(0)
 
money = 1000
previous_tendency = "remain"
current_tendency = "remain"
count = 1

 
for n in range(1,len(A)-1):
    if A[n] < A[n+1]:
        current_tendency = "up"
    elif A[n] > A[n+1]:
        current_tendency = "down"
    else:
        current_tendency = "remain"
        
    if previous_tendency != "down" and current_tendency != "up":
        #print(money,n,"chance",A[n],min(A[count:n+1]),previous_tendency, current_tendency)
        money += (money//min(A[count:n+1]))*(A[n]-min(A[count:n+1]))
        #print(A[count:n+1],money)
        count = n + 1
        previous_tendency = "remain"
    #print(A[n],max_price,min_price,previous_tendency,current_tendency)
    
    if current_tendency != "remain":
      previous_tendency = current_tendency
print(money)

### FIXED CODE ###

N = int(input())
print(10-(N//200))
N = int(input())
A = [list(map(int,input().split())) for i in range(N)]
a_max = max(A)[0]
count = A.count(a_max)

for i in range(N):
	if A[i] < a_max and count >= 2:
		print(a_max)
	else:
		b_max = 0
		for i in range(N):
				if A[i] == a_max:
					continue
				if A[i] > b_max:
					b_max = A[i]
		print(b_max)


### FIXED CODE ###

N = int(input())
A = [int(input()) for i in range(N)]
a_max = int(max(A))
count = A.count(a_max)

for i in range(N):
	if A[i] < a_max or count >= 2:
		print(a_max)
	else:
		b_max = 0
		for j in range(N):
				if A[j] == a_max:
					continue
				if A[j] > b_max:
					b_max = A[j]
		print(b_max)
N = int(input())
XYH = [0] * N
for i in range(N):
  x, y, h = map(int, input().split())
  XYH[i] = [x, y, h]
XYH.sort(key=lambda x: x[2])
H = 0
for cx in range(101):
  for cy in range(101):
    _H = abs(cx - XYH[0][0]) + abs(cy - XYH[0][1]) + XYH[0][2]
    for x, y, h in XYH[1:]:
      if h and abs(cx - x) + abs(cy - y) + h != _H:
        break
    else:
      Cx = cx
      Cy = cy
      H = _H
    if H:
      break
  if H:
    break
print(Cx, Cy, H)

### FIXED CODE ###

N = int(input())
XYH = [0] * N
for i in range(N):
  x, y, h = map(int, input().split())
  XYH[i] = [x, y, h]
XYH.sort(key=lambda x: x[2], reverse=True)
H = 0
for cx in range(101):
  for cy in range(101):
    _H = abs(cx - XYH[0][0]) + abs(cy - XYH[0][1]) + XYH[0][2]
    for x, y, h in XYH[1:]:
      if h != max(_H - abs(cx - x) - abs(cy - y), 0):
        break
    else:
      Cx = cx
      Cy = cy
      H = _H
    if H:
      break
  if H:
    break
print(Cx, Cy, H)
L=[1]
n=int(input())
x = 6
y = 9
while x <= n:
  L.append(x)
  x *= 6
while y <= n:
  L.append(y)
  y *= 9
L.sort()#[1,6,9,36,81]
dp = [float("Inf")]*(n+1)
dp[0] = 0
for i in range(n+1):#0~81
  for j in L:#1,6,9
    dp[i+j] = min(dp[i+j],dp[i]+1)#dp=[0,1,...1,.1]
print(dp[n])

### FIXED CODE ###

L=[1]
n=int(input())
x = 6
y = 9
while x <= n:
  L.append(x)
  x *= 6
while y <= n:
  L.append(y)
  y *= 9
L.sort()#[1,6,9,36,81]
dp = [float("Inf")]*(n+1)
dp[0] = 0
for i in range(n+1):#0~81
  for j in L:#1,6,9
    if i+j <= n:
      dp[i+j] = min(dp[i+j],dp[i]+1)#dp=[0,1,...1,.1]
    else:
      break
print(dp[n])
input()
s = list(map(int, input().split()))

cnt = 0
while True:
    if len(n for n in s if n % 2 != 0) != 0:
        print (cnt)
        break
    else:
        s = list(map(lambda n: n / 2, s))
        cnt = cnt + 1



### FIXED CODE ###

input()
s = list(map(int, input().split()))

cnt = 0
while True:
    if len([n for n in s if n % 2 != 0]) != 0:
        print (cnt)
        break
    else:
        s = list(map(lambda n: n / 2, s))
        cnt = cnt + 1
import sys
from collections import deque

input = sys.stdin.readline


def main():
    N = int(input())
    A = [0] * N
    for i in range(N):
        A[i] = int(input())

    A.sort()
    d = deque(A)
    min_A = d.popleft()
    max_A = d.pop()
    ans = max_A - min_A
    v1 = min_A
    v2 = max_A
    while d:
        if len(d) == 1:
            v = d.pop()
            ans += max(abs(v1 - v), abs(v2 - v))
        else:
            v_min = d[0]
            v_max = d[-1]
            diff = 0
            is_popleft = True
            if diff < abs(v1 - v_min):
                diff = abs(v1 - v_min)
                next_v1 = v_min
                next_v2 = v2
            if diff < abs(v2 - v_min):
                diff = abs(v2 - v_min)
                next_v1 = v_min
                next_v2 = v1
            if diff < abs(v1 - v_max):
                diff = abs(v1 - v_max)
                next_v1 = v_max
                next_v2 = v2
                is_popleft = False
            if diff < abs(v2 - v_max):
                diff = abs(v2 - v_max)
                next_v1 = v_max
                next_v2 = v1
                is_popleft = False
            ans += diff
            v1, v2 = next_v1, next_v2
            if is_popleft:
                d.popleft()
            else:
                d.pop()

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
from collections import deque

input = sys.stdin.readline


def main():
    N = int(input())
    A = [0] * N
    for i in range(N):
        A[i] = int(input())

    A.sort()
    d = deque(A)
    min_A = d.popleft()
    max_A = d.pop()
    ans = max_A - min_A
    v1 = min_A
    v2 = max_A
    while d:
        if len(d) == 1:
            v = d.pop()
            ans += max(abs(v1 - v), abs(v2 - v))
        else:
            v_min = d[0]
            v_max = d[-1]
            diff = 0
            is_popleft = None
            if diff < abs(v1 - v_min):
                diff = abs(v1 - v_min)
                next_v1 = v_min
                next_v2 = v2
                is_popleft = True
            if diff < abs(v2 - v_min):
                diff = abs(v2 - v_min)
                next_v1 = v_min
                next_v2 = v1
                is_popleft = True
            if diff < abs(v1 - v_max):
                diff = abs(v1 - v_max)
                next_v1 = v_max
                next_v2 = v2
                is_popleft = False
            if diff < abs(v2 - v_max):
                diff = abs(v2 - v_max)
                next_v1 = v_max
                next_v2 = v1
                is_popleft = False
            if is_popleft is None:
                next_v1 = v_min
                next_v2 = v2
                is_popleft = True
            ans += diff
            v1, v2 = next_v1, next_v2
            if is_popleft:
                d.popleft()
            else:
                d.pop()

    print(ans)


if __name__ == "__main__":
    main()
N = int(input())
num = 1
flag = 0
c=list(map(int, input().split()))
for i in c:
    if i == 0:
        flag = 1
        print("0")
if flag == 0:
    for i in c:
        num *= i
    if num > 1000000000000000000:
        print("-1")
    else:
        print(num)

### FIXED CODE ###

a,b=map(int, input().split())
print(a*b)
import math
from functools import reduce

N, X = [int(c) for c in input().split()]
x = [int(c) for c in input().split()]

if N == 1:
    print(x[0] - X)
else:
    x.append(X)
    x.sort()
    x = [n - x[0] for n in x]
    D = reduce(math.gcd, x)
    print(D)

### FIXED CODE ###

#import math
from functools import reduce

N, X = [int(c) for c in input().split()]
x = [int(c) for c in input().split()]

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

if N == 1:
    print(abs(x[0] - X))
else:
    x.append(X)
    x.sort()
    x = [n - x[0] for n in x]
    D = reduce(gcd, x)
    print(D)
top=0
sum=0
asp=0
n,m=list(map(int,input().split()))
a=list(map(int,input().split()))

for i in range(n):
    sum=sum+int(a[i-1])
    if a[i-1]<a[i] or i==1:
        top=int(a[i-1])

asp=float(1-(1/(4*m)))
asc=float((1/(4*m))
if top>sum*asp or top/asp>sum:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

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

new_a=sorted(a,reverse=True)
sums=sum(a)

if new_a[m-1]>=sums/(m*4):
    print("Yes")
else:
    print("No")
N,A,B=map(int,input().split())


s=0

if A==0:
    print(0)
else:
    a=N//(A+B)
    b=N%(A+B)

    # print(a)
    # print(b)
    if b>A:
    sum=A*a+A
    print(s)
    else:
    s=A*a+b
    print(s)

### FIXED CODE ###

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


sum=0

if A==0:
    print(0)
else:
    a=N//(A+B)
    b=N%(A+B)

    # print(a)
    # print(b)
    if b>=A:
        sum=A*a+A
        print(sum)
    if b<A:
        sum=A*a+b
        print(sum)
a,b,c = input().split()

if (a== b) and (a==c) and (b==C):
  ans = "No"
else:
  ans = "Yes"
print(ans)

### FIXED CODE ###

a,b,c = list(input())
print("No") if a==b and b==c and c==a else print("Yes")
N=int(input())
A=list(map(int,input().split()))
l=[]
for a in A:
  b=0
  while a%2==0:
    a//=2
  	b+=1
  l.append(b)
print(min(l))

### FIXED CODE ###

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

for a in A:
    b=0
    while a%2==0:
        a//=2
        b+=1
    l.append(b)
print(min(l))
s = input()

def f(t):
    if len(t) > len(s):
        return False
    if t == s:
        return True
    return f(t + 'dream') or f(t + 'erase') or f(t + 'dreamer') or f(t + 'eraser')

if f(''):
    print('YES')
else:
    print('NO')

### FIXED CODE ###

s = list(input())
while len(s) > 0:
    if ''.join(s[-7:]) == 'dreamer':
        del s[-7:]    
    elif ''.join(s[-6:]) == 'eraser':
        del s[-6:]
    elif ''.join(s[-5:]) == 'dream' or ''.join(s[-5:]) == 'erase':
        del s[-5:]
    else:
        break
print('NO' if len(s) != 0 else 'YES')
N, K = map(int, input().split())
S = input()
l = [1]
for i in range(N-1):
  if S[i] == S[i+1]:
    l[-1] += 1
  else:
    l.append(1)
  if S[0] == 0:
    l = [0] + l
  if S[-1] == 0:
    l += [0]
#print(l)
n = len(l)
ans = sum(l[:min(K*2+1, n+1)])
i = 0
M = ans
while True:
  if K*2 + i+1 >= n:
    break
  M = M + l[K*2+1 + i] + l[K*2+1 + i+1] - l[i] -l[i+1]
  #print(ans, M)
  ans = max(ans, M)
  i += 2
print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
S = input()
l = [1]
for i in range(N-1):
  if S[i] == S[i+1]:
    l[-1] += 1
  else:
    l.append(1)
if S[0] == "0":
  l = [0] + l
if S[-1] == "0":
  l += [0]
#print(l)
n = len(l)
ans = sum(l[:min(K*2+1, n+1)])
i = 0
M = ans
while True:
  if K*2 + i+1 >= n:
    break
  M = M + l[K*2+1 + i] + l[K*2+1 + i+1] - l[i] -l[i+1]
  #print(ans, M)
  ans = max(ans, M)
  i += 2
print(ans)
a,b = map(int,input().split())
if (a+b)%3 == 0:
  a == a - min(a,b)
  b == b - min(a,b)
  c = a+b
  import math
  aa = math.factorial(a)
  bb = math.factorial(b)
  cc = math.factorial(c)
  print((cc/(bb*aa))%(10**9+7))
else:
  print(0)

### FIXED CODE ###

import math
import numpy as np

def cmb(n, r, mod):
  r = min(r, n-r)
  return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 
N = 10**6
g1 = [1, 1] 
g2 = [1, 1] 
inverse = [0, 1] 

for i in range( 2, N + 1 ):
  g1.append( ( g1[-1] * i ) % mod )
  inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
  g2.append( (g2[-1] * inverse[-1]) % mod )

x,y = map(int,input().split()) 

if (x+y) % 3 == 0:

  A = np.array([[1, 2],
                [2, 1]])

  b = np.array([x, y])

  N = np.linalg.solve(A, b)


  if N[0].is_integer() == True and N[1].is_integer() == True and N[0] >=0 and N[1] >=0:
        
      print(cmb(int(N[0]+N[1]),int(N[0]),mod))

  else:
      print(0)

else:
  print(0)
#!/usr/bin/env python
# coding: utf-8

import math


def main():
    x1, y1, x2, y2 = [int(i) for i in raw_input().split(" ")]
    if x1 < x2:
        x1, x2 = x2, x1
    w = x1 - x2
    if y1 < y2:
        y1, y2 = y2, y1
    h = y1 - y2
    print "%1.5f" % math.sqrt(w ** 2 + h ** 2)

if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin/env python
# coding: utf-8

import math


def main():
    x1, y1, x2, y2 = [float(i) for i in raw_input().split(" ")]
    if x1 < x2:
        x1, x2 = x2, x1
    w = x1 - x2
    if y1 < y2:
        y1, y2 = y2, y1
    h = y1 - y2
    print "%1.8f" % math.sqrt(w ** 2 + h ** 2)

if __name__ == '__main__':
    main()
import numpy as np
a = np.array(input().split()).astype(int)
flags = (np.diff(a) <= 0).astype(int)
result = 0
results = []
for i, flag in enumerate(flags):
    if flag == 0:
        results.append(result)
        result = 0
    elif flag == 1 and i != len(flags) - 1:
        result += 1
    else:
        result += 1
        results.append(result)
print(max(results))

### FIXED CODE ###

import numpy as np
N = input()
a = np.array(input().split()).astype(int)
flags = (np.diff(a) <= 0).astype(int)
result = 0
max_result = 0
for i, flag in enumerate(flags):
    if flag == 0:
        if result > max_result:
            max_result = result
        result = 0
    else:
        result += 1
    if i == len(flags) - 1:
        if result > max_result:
            max_result = result
print(max_result)
for e in iter(input,'0'):
 e=int(e)
 print(sum(n//5**i)for i in range(1,6)))


### FIXED CODE ###

for e in iter(input,'0'):print(sum(int(e)//5**i for i in range(1,7)))
h,w=map(int,input().split())
g=[]
for i in range(h):
    g.append(list(input()))
q=[]
v=[[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        if g[i][j]=='#':
            q.append([i,j])
            v[i][j]=1
ans=0
while len(q)>0:
    tmp=[]
    for i in q:
        a=i[0]
        b=i[1]
        if a==0:
            hi=[1]
        elif a==h-1:
            hi=[-1]
        else:
            hi=[1,-1]
        if b==0:
            wi=[1]
        elif b==w-1:
            wi=[-1]
        else:
            wi=[1,-1]
        for c in hi:
            if v[a+c][b]==0:
                tmp.append([a+c,b])
                v[a+c][b]=1
        for d in wi:
            if v[a][b+d]==0:
                tmp.append([a,b+d])
                v[a][b+d]=1
    q=tmp
    ans+=1
print(ans-1)


### FIXED CODE ###

h,w=map(int,input().split())
g=[]
for i in range(h):
    g.append(list(input()))
q=[]
v=[[0 for i in range(w)] for j in range(h)]
for i in range(h):
    for j in range(w):
        if g[i][j]=='#':
            q.append([i,j])
            v[i][j]=1
ans=0
while len(q)>0:
    tmp=[]
    for i in q:
        a=i[0]
        b=i[1]
        if a==0:
            hi=[1]
        elif a==h-1:
            hi=[-1]
        else:
            hi=[1,-1]
        if h==1:
            hi=[]
        if b==0:
            wi=[1]
        elif b==w-1:
            wi=[-1]
        else:
            wi=[1,-1]
        if w==1:
            wi=[]
        for c in hi:
            if v[a+c][b]==0:
                tmp.append([a+c,b])
                v[a+c][b]=1
        for d in wi:
            if v[a][b+d]==0:
                tmp.append([a,b+d])
                v[a][b+d]=1
    q=tmp
    ans+=1
print(ans-1)
ab = input().split(' ')
print(max(ab[0]*int(ab[1]), ab[1]*int(ab[0]))

### FIXED CODE ###

ab = input().split(' ')
print(min(ab[0]*int(ab[1]), ab[1]*int(ab[0])))
N = int(input())
ans_lis = [[0　for _ in range(9)] for  i in range(9)]
for i in range(1,N+1):
  t = str(i)
  mae = int(t[0])
  ushiro = int(t[-1])
  ans_lis[mae-1][ushiro-1] += 1
ans = 0
for i in range(9):
  for j in range(9):
    ans += ans_lis[i][j] * ans_lis[j][i]
print(ans)

### FIXED CODE ###

N = int(input())
ans_lis = [[0] * 9 for i in range(9)]
for i in range(1,N+1):
  t = str(i)
  mae = int(t[0])
  ushiro = int(t[-1])
  if ushiro == 0:
    continue
  ans_lis[mae-1][ushiro-1] += 1
ans = 0
for i in range(9):
  for j in range(9):
    ans += ans_lis[i][j] * ans_lis[j][i]
print(ans)
N,M=map(int,input().split())
big=10**13
from collections import defaultdict
branch=defaultdict(set)
for i in range(M):
    a,b,c=map(int,input().split())
    branch[a]|={(b,c),}
def dps(now,score,visited,ans):
    if now==N:
        ans=max(score,ans)
    if len(branch[now])==0:
        return ans
    for b,c in branch[now]:
        if ans>big:return ans
        if  b in visited:
            return float('inf')
        ans=dps(b,score+c,visited|{now,},ans)
    return ans
print(dps(1,0,set(),-1*float('inf')))

### FIXED CODE ###

N,M=map(int,input().split())
big=10**13
data=[-1*float('inf')]*(N+1)
from collections import defaultdict
branch=defaultdict(set)
for i in range(M):
    a,b,c=map(int,input().split())
    branch[a]|={(b,c),}
from collections import deque
check=deque()
check.append((1,0,set()))
data[1]=0
while len(check)>0:
    now=check.popleft()
    for b,c in branch[now[0]]:
        if now[1]+c>data[b]:
            if data[b]>big:continue
            if b in now[2]:
                data[b]=float('inf')
                check.append((now[0],float('inf'),now[2]|{now[0],b}))
                check.append((b,float('inf'),now[2]|{now[0],b}))
            else:
                data[b]=now[1]+c
                check.append((b,now[1]+c,now[2]|{now[0],}))
if data[N]>big:print('inf')
else:print(data[N])