Harryxun/stf_run huggingface dataset:
class int(int):  
  def times(self, callback):
    for times in range(0,self):
      callback()

class list(list):
  def maps(self, callback):
    return list(map(callback, self))

  def each(self, callback):
    list(map(callback, self))
    return self

  # index will sent to the function as a second parameter.
  def each_with_index(self,callback):
    list(map(callback, self, range(0,len(self))))
    return self

# Make sure you initialize object with class name.
# Ex: int(10).times, array = list([1,2,3,4,5])

target, length = input().split()
target = int(target)
length = int(length)
o_nums = list(input().split())

if length > 1:
  def convert(arg):
    return int(arg)

  o_nums = o_nums.maps(convert)
  diffs = list()
  nums = list()
  for exclude_num in range(min(o_nums), max(o_nums)+1):
    if exclude_num in o_nums:
      continue
    else:
      nums.append(exclude_num)

  for num in nums:
    diffs.append(target - num)

  def absm(arg):
    return abs(arg)

  diffs_abs = diffs.maps(absm)
  smallest_diff_index = diffs_abs.index(min(diffs_abs)) #絶対値が最も小さいもの

  if -(diffs_abs[smallest_diff_index]) in diffs: # ターゲットよりも小さい、最も差分が小さい値を探す
    index = diffs.index(-(diffs_abs[smallest_diff_index]))
    print(nums[index])
  else:
    print(nums[smallest_diff_index])

elif length == 1:
  print(o_nums[0])

else:
  print(target)

### FIXED CODE ###

class int(int):  
  def times(self, callback):
    for times in range(0,self):
      callback()

class list(list):
  def maps(self, callback):
    return list(map(callback, self))

  def each(self, callback):
    list(map(callback, self))
    return self

  # index will sent to the function as a second parameter.
  def each_with_index(self,callback):
    list(map(callback, self, range(0,len(self))))
    return self

# Make sure you initialize object with class name.
# Ex: int(10).times, array = list([1,2,3,4,5])

target, length = input().split()
target = int(target)
length = int(length)
nums = list(input().split())

def convert(arg):
    return int(arg)
nums = nums.maps(convert)

for i in range(0,101):
  a = target - i
  if a not in nums:
    print(a)
    exit()

  b = target + i
  if b not in nums:
    print(b)
    exit()
ns,k = input().split()
nlist = input().split()
nslist = list(ns)
while set(nslist) & set(nlist):
    ns = int(ns)+1
    ns = str(ns)
    nslist = list(ns)
print(ns)


### FIXED CODE ###

go=0
nana=0
num = input().split()
for i in num:
  if i == "5":
    go+=1
  if i == "7":
    nana+=1
if (go==2) and (nana==1):
  print("YES")
else:
  print("NO")
N = int(input())

if N == 2:
  print(1)
  exit()

ans = 0

def factorization(n):
  lis = []
  if n % 2 == 0:
    c = 0
    while n%2 == 0:
      n //= 2
      c += 1
    lis.append([2, c])
  k = 3
  while k*k <= n:
    if n%k == 0:
      c = 0 
      while n%k == 0:
        n //= k
        c += 1
      lis.append([k, c])
    else:
      k += 2
  if n > 1:
    lis.append([n, 1])
  return lis

list1 = factorization(N-1)
ans1 = 1
for k in range(len(list1)):
  ans1 *= list1[k][1]+1
ans += ans1-1

def operation(K):
  while N%K == 0:
    N //= K
  if N%K == 1:
    return True
  else:
    return False

list2 = factorization(N)
factorlist = [1]
for l in range(len(list2)):
  list3 = []
  for j in range(list2[l][1]):
    for k in range(len(factorlist)):
      list3.append(factorlist[k]*list2[l][0]**(j+1))
  factorlist += list3
factorlist = factorlist[1:-1]
ans += 1
for item in factorlist:
  if operation(item):
    ans +=1
print(ans)

### FIXED CODE ###

N = int(input())
originalN = 0 +N
if N == 2:
  print(1)
  exit()
ans = 0
primenum = [2]
count = [0 for _ in range(int(N**0.5)+2)]
for k in range(3, len(count), 2):
  if count[k] == 0:
    primenum.append(k)
    for j in range(k, len(count), k):
      count[j] = 1
    
def factorization(n):
  lis = []
  k = 0
  while primenum[k] <= n:
    if n%primenum[k] == 0:
      c = 0 
      while n%primenum[k] == 0:
        n //= primenum[k]
        c += 1
      lis.append([primenum[k], c])
    else:
      k += 1
      if k > len(primenum)-1:
        break
  if n > 1:
    lis.append([n, 1])
  return lis

list1 = factorization(N-1)
#print(factorization(N-1))
ans1 = 1
for k in range(len(list1)):
  ans1*= list1[k][1]+1
ans1 -= 1
ans += ans1

#print(ans1)

def operation(K):
  N = originalN
  while N%K == 0:
    N //= K
  if N%K == 1:
    return True
  else:
    return False

list2 = factorization(N)
#print(list2)
factorlist = [1]

for l in range(len(list2)):
  list3 = []
  for j in range(list2[l][1]):
    for k in range(len(factorlist)):
      list3.append(factorlist[k]*list2[l][0]**(j+1))
  factorlist += list3

factorlist = factorlist[1:-1]
#print(factorlist)
ans2 = 1
for item in factorlist:
  if operation(item):
    #print(item)
    ans2 +=1


ans += ans2
#print(ans2)

print(ans)
H = input()

i = 0
while 2 ** i <= H:
  i += 1
print(2 ** i - 1)

### FIXED CODE ###

H = input()

i = 0
while 2 ** i <= int(H):
  i += 1
print(2 ** i - 1)
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n,m=map(int, input().split())
a = 0
b = 0
if n != 1:
  a = cmb(n, 2)  
if m != 1:
  b = cmb(m,2)
print(a+b)

### FIXED CODE ###

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n,m=map(int, input().split())
a = 0
b = 0
if n > 1:
  a = cmb(n, 2)  
if m > 1:
  b = cmb(m,2)
print(a+b)
L, R = map(int, input().split())
l = L % 2019
r = R % 2019
w = R - L
if s + w >= 2019:
  print(0)
else:
  print(min((s * (s + 1))% 2019, (l * (l - 1)) % 2019)

### FIXED CODE ###

L, R = map(int, input().split())
l = L % 2019
r = R % 2019
w = R - L
if l + w >= 2019:
  print(0)
else:
  ans = 2019
  for i in range(l, r + 1):
    for j in range(i + 1, r + 1):
      ans = min(ans, (i * j) % 2019)
  print(ans)
n, k = map(int, input().split())
s = input()

part1 = s[:k - 1]
part2 = s[k - 1].lower()
part3 = s[k:]

print(f'{part1}{part2}{part3}')


### FIXED CODE ###

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

print(a * b)
n = input()
ans = 0
if len(n) % 2 == 0:
    length = len(n) - 1
    for i in range(length, -1, -2):
        if i == 1:
            ans += 9
        else:
            plus = '9' * i
            minus = '9' * (i - 1)
            ans += (int(plus) - int(minus))
    print(ans)
else:
    length = len(n)
    b = '9' * (length-1)
    c = int(n) - int(b)
    ans += c
    for i in range(length-2, -1, -2):
        if i == 1:
            ans += 9
        else:
            plus = '9' * i
            minus = '9' * (i-1)
            ans += (int(plus) - int(minus))
    print(ans)

### FIXED CODE ###

n = input()
ans = 0
if len(n) % 2 == 0:
    length = len(n) - 1
    for i in range(length, -1, -2):
        if i == 1:
            ans += 9
        else:
            plus = '9' * i
            minus = '9' * (i - 1)
            ans += (int(plus) - int(minus))
    print(ans)
else:
    if int(n) <= 9:
        print(int(n))
    else:
        length = len(n)
        b = '9' * (length-1)
        c = int(n) - int(b)
        ans += c
        for i in range(length-2, -1, -2):
            if i == 1:
                ans += 9
            else:
                plus = '9' * i
                minus = '9' * (i-1)
                ans += (int(plus) - int(minus))
        print(ans)
n, x = map(int, input().split())
m_list = []
for _ in range(n):
  m_list.append(int(input()))

print(n + (x - sum(x_list))//min(x_list))


### FIXED CODE ###

n, x = map(int, input().split())
m_list = []
for _ in range(n):
  m_list.append(int(input()))

print(n + (x - sum(m_list))//min(m_list))
t = list(input())

for i in range(len(t)):
    if t[i] == '?' and t[i-1] =='P':
        t[i] = 'D'
    elif t[i] == '?' and t[i+1] =='D':
        t[i] = 'P'
    elif t[i] == '?' and t[i+1] =='?':
        t[i] = 'P'
        t[i+1] = 'D'

print(''.join(t))

### FIXED CODE ###

t = input()

print(t.replace('?', 'D'))
A, B, T = map(int, input().split())
int sum = 0
int t = 0
while(t <= T):
  if t%A == 0:
    sum += B
  t += 1
print(sum)


### FIXED CODE ###

A, B, T = map(int, input().split())
cnt = T // A
ans = B * cnt
print(ans)
n=int(input())
x=input()
chk0=chk1=chk2=0
b=x.count("1")
if b==1 and x=="1":
    print(0//0)
    exit()
elif b==1 and x[-1]=="1":
    for i in range(n-1):
        print(2//0)
    print(0)
    exit()
elif b==1:
    for i in range(n):
        if i=="0": print(1//0)
        else: print(0//0)
    exit()
for i,j in enumerate(x[::-1]):
    if j=="1":
        chk1+=pow(2,i,b+1)
        if b>1: chk2+=pow(2,i,b-1)
        else: chk2=0
l=[]
for i,j in enumerate(x[::-1]):
    if b: a1=pow(2,i,b+1)
    else: a1=1
    if b>1: a2=pow(2,i,b-1)
    else: a2=1
    if j=="0":
        t=chk1+a1
    else:
        if b>1: t=chk2+b-1-a2
        else: t=0
    ans,f=0,1
    while t:
        if f:
            if j=="0": t%=(b+1)
            else: t%=(b-1)
            f=0
        else:
            t%=bin(t).count("1")
        ans+=1
    l.append(ans)
for i in l[::-1]:
    print(i)

### FIXED CODE ###

n=int(input())
x=input()
chk0=chk1=chk2=0
b=x.count("1")
if b==1 and x=="1":
    print(0)
    exit()
elif b==1:
    for i in range(n):
        if i==n-1: print(2)
        elif x[i]=="0": print(1)
        else: print(0)
    exit()
for i,j in enumerate(x[::-1]):
    if j=="1":
        chk1+=pow(2,i,b+1)
        if b>1: chk2+=pow(2,i,b-1)
        else: chk2=0
l=[]
for i,j in enumerate(x[::-1]):
    if b: a1=pow(2,i,b+1)
    else: a1=1
    if b>1: a2=pow(2,i,b-1)
    else: a2=1
    if j=="0":
        t=chk1+a1
    else:
        if b>1: t=chk2+b-1-a2
        else: t=0
    ans,f=0,1
    while t:
        if f:
            if j=="0": t%=(b+1)
            else: t%=(b-1)
            f=0
        else:
            t%=bin(t).count("1")
        ans+=1
    l.append(ans)
for i in l[::-1]:
    print(i)
import math
N, P = list(map(int, input().split()))

def cal(x):
    if P % (x ** N) == 0:
        return x
    return cal(x-1)

print(cal(int(math.pow(P, 1/ N))+1))

### FIXED CODE ###

n, p = map(int, input().split())
if n == 1:
    print(p)
else:
    for i in range(1, round(p**(1/n))+1):
        if p % i**n ==0:
            res = i
    print(res)
n,m=map(int,input().split())
wa=0
ac=0
check = [0]*n
for _ in range(m):
	a, b = input().split()
	if check[int(a)]==0:
		if b == "WA":
			wa+=1
		elif b == "AC":
			ac+=1
			check[int(a)]=1
print(ac,wa)

### FIXED CODE ###

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

ac = [False] * N
wa = [0] * N
for _ in range(M):
    p, S = input().split()
    p = int(p) - 1
    if S == 'AC':
        ac[p] = True
    else:
        if not ac[p]:
            wa[p] += 1

a = 0
b = 0
for i in range(N):
    if ac[i]:
        a += 1
        b += wa[i]
print(*[a, b])
h, w = map(int, input().split())
s = [input() for _ in range(h)]
seen = [[False for _ in range(w)] for _ in range(h)]

def dfs(bx, by, sx, sy):
    if s[sx][sy] == '.':
        b_cnt, w_cnt = 0, 1
    else:
        b_cnt, w_cnt = 1, 0
    for dx, dy in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
        px, py = sx + dx, sy + dy
        #print('=', px, py)
        if bx == px and by == py:
            #print(px, py, 'flg1')
            continue
        if px < 0 or h <= px or py < 0 or w <= py:
            #print(px, py, 'flg2')
            continue
        if seen[px][py]:
            #print(px, py, 'flg3')
            continue
        if s[sx][sy] == s[px][py]:
            #print(px, py, 'flg4')
            continue
        seen[px][py] = True
        b_add, w_add = dfs(sx, sy, px, py)
        b_cnt += b_add
        w_cnt += w_add

    return b_cnt, w_cnt

ans = 0
#print(dfs(-1, -1, 1, 1))
for i in range(h):
    for j in range(w):
        if seen[i][j] == False:
            seen[i][j] = True
            b_cnt, w_cnt = dfs(-1, -1, i, j)
            ans += b_cnt * w_cnt

print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 7)
h, w = map(int, input().split())
s = [input() for _ in range(h)]
seen = [[False for _ in range(w)] for _ in range(h)]

def dfs(bx, by, sx, sy):
    if s[sx][sy] == '.':
        b_cnt, w_cnt = 0, 1
    else:
        b_cnt, w_cnt = 1, 0
    for dx, dy in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
        px, py = sx + dx, sy + dy
        #print('=', px, py)
        if bx == px and by == py:
            #print(px, py, 'flg1')
            continue
        if px < 0 or h <= px or py < 0 or w <= py:
            #print(px, py, 'flg2')
            continue
        if seen[px][py]:
            #print(px, py, 'flg3')
            continue
        if s[sx][sy] == s[px][py]:
            #print(px, py, 'flg4')
            continue
        seen[px][py] = True
        b_add, w_add = dfs(sx, sy, px, py)
        b_cnt += b_add
        w_cnt += w_add

    return b_cnt, w_cnt

ans = 0
#print(dfs(-1, -1, 1, 1))
for i in range(h):
    for j in range(w):
        if seen[i][j] == False:
            seen[i][j] = True
            b_cnt, w_cnt = dfs(-1, -1, i, j)
            ans += b_cnt * w_cnt

print(ans)
def pairwise_distinct():
    n = int(input())
    k = []
    for i in range(0,n):
        k.append(int(input()))
    if (len(set(k)) == len(k)):
        return "YES"
    else:
        return "NO"

    return k
        
        

print(pairwise_distinct())

### FIXED CODE ###

def pairwise_distinct():
    n = int(input())
    k = list(input().split())
    if (len(set(k)) == len(k)):
        return "YES"
    else:
        return "NO"

print(pairwise_distinct())
import fractions
from functools import reduce
n=int(input())
numbers=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
l=0
x=lcm_list(numbers)
for i in range(n):
    l+=(x//numbers[i])
print(l%(10**9+7))


### FIXED CODE ###

n,m=map(int,input().split())
if n==m:
  print("Yes")
else:
  print("No")
n=int(input())
alis=list(map(int,input().split()))
xlis=set(alis)
for al in alis:
    alis.add(al-1)
    alis.add(al+1)
counter=[0 for _ in range(n)]
for x in xlis:
    for i in range(n):
        if x-1<=alis[i]<=x+1:
            counter[i]+=1
print(max(counter))

### FIXED CODE ###

n=int(input())
alis=list(map(int,input().split()))
xlis=dict()
for i in set(alis):
    xlis[i-1]=0
    xlis[i+1]=0
    xlis[i]=0
for i in alis:
    xlis[i-1]+=1
    xlis[i+1]+=1
    xlis[i]+=1
print(max(xlis.values()))
S =  int(input('How many sheep'))
W =  int(input('How many wolf'))
if W >= S:
    print('unsafe')
else:
    print('safe')

### FIXED CODE ###

S,W = input().split()
if int(W) >= int(S):
    print('unsafe')
else:
    print('safe')
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
from functools import reduce
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def lcm_base(a, b):
    return (a * b) // gcd(a, b)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def nCr(n,r):
  bunshi = 1
  bunbo = 1
  for i in range(r):
    bunshi = (bunshi * (n-i)) % MOD
    bunbo = (bunbo * (i+1)) % MOD
  return bunshi * pow(bunbo, MOD - 2, MOD) % MOD


def main():
  X, Y = map(int, readline().split())
  if (x + y) % 3 != 0 or (2 * x - y) % 3 != 0 or (2 * y - x) % 3 != 0:
    print(0)
    sys.exit()
  else:
    n = (2*Y - X)//3
    m = (2*X - Y)//3
    ans = nCr(n+m, n)
  print(ans%MOD)
  
  
  
if __name__ == '__main__':
  main()

### FIXED CODE ###

from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
import numpy as np
from collections import deque, Counter, defaultdict
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
from functools import reduce
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
def lcm_base(a, b):
    return (a * b) // gcd(a, b)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def nCr(n,r):
  bunshi = 1
  bunbo = 1
  for i in range(r):
    bunshi = (bunshi * (n-i)) % MOD
    bunbo = (bunbo * (i+1)) % MOD
  return bunshi * pow(bunbo, MOD - 2, MOD) % MOD


def main():
  X, Y = map(int, readline().split())
  if (X + Y) % 3 != 0 or (2 * X - Y) % 3 != 0 or (2 * Y - X) % 3 != 0:
    print(0)
    sys.exit()
  else:
    n = (2*Y - X)//3
    m = (2*X - Y)//3
    if n<0 or m<0:
      print(0)
      sys.exit()
    ans = nCr(n+m, n)
  print(ans%MOD)
  
  
  
if __name__ == '__main__':
  main()
X,Y = map(int,input().split())
# 何回移動するか
r = (X+Y)//3
# 移動の可能性 rC(x-r)
from functools import reduce
mod = 10**9+7
if (X+Y)%3==0:
    r = (X+Y)//3
    if r != X and r != Y:
        if r != X*0.5 and r != Y*0.5:
        num = reduce(lambda x,y:x*y%mod,[k+1 for k in range(r)])
        p = reduce(lambda x,y:x*y%mod,[k+1 for k in range(X-r)])
        q = reduce(lambda x,y:x*y%mod,[k+1 for k in range(2*r-X)])
        ans = num*pow(p,mod-2,mod)*pow(q,mod-2,mod)%mod
        print(ans%mod)  
        else:
            num = reduce(lambda x,y:x*y%mod,[k+1 for k in range(r)])
            p = reduce(lambda x,y:x*y%mod,[k+1 for k in range(X-r)])
            ans = num*pow(p,mod-2,mod)%mod
            print(ans%mod)  
    else:
        print(1)
else:
    print(0)

### FIXED CODE ###

X,Y = map(int,input().split())
# 何回移動するか
r = (X+Y)//3
# 移動の可能性 rC(x-r)
from functools import reduce
mod = 10**9+7

if (X+Y)%3==0 and X<= 2*Y and Y<= 2*X :
    r = (X+Y)//3
    l = min
    if r != X and r != Y:
        num = reduce(lambda x,y:x*y%mod,[k+1 for k in range(r)])
        p = reduce(lambda x,y:x*y%mod,[k+1 for k in range(X-r)])
        q = reduce(lambda x,y:x*y%mod,[k+1 for k in range(2*r-X)])
        ans = num*pow(p,mod-2,mod)*pow(q,mod-2,mod)%mod
        print(ans%mod)   
    else:
        print(1)
else:
    print(0)
a, b = map(int,input().split())
if a > b:
	print(“a > b”)
elif a < b:
	print(“a < b”)
else:
	print(“a == b”)



### FIXED CODE ###

a,b = map(int, input().split())
if a > b:
 print("a > b")
elif a < b:
 print("a < b")
else:
 print("a == b")
import math
n = int(input())
for i in range(n):
    a,b,c,d = map(int,input().split())
    if a < b:
        print("No")
    elif b > d:
        print("No")
    elif c >= b:
        print("Yes")
    else:
        g = math.gcd(b,d)
        if b-g+(a%g) > c:
            print("No")
        else:
            print("Yes")

### FIXED CODE ###

def gcd(x,y):
    if x < y:
        tmp = y
        y = x
        x = tmp

    while x % y != 0:
        r = x % y
        x = y
        y = r
    return y

n = int(input())
x = []
for i in range(n):
    a,b,c,d = map(int,input().split())
    x.append((a,b,c,d))

def f(a,b,c,d):
    if a < b:
        print("No")
    elif b > d:
        print("No")
    elif c >= b:
        print("Yes")
    else:
        g = gcd(b,d)
        if b-g+(a%g) > c:
            print("No")
        else:
            print("Yes")

for i in range(n):
    a,b,c,d = x[i][0],x[i][1],x[i][2],x[i][3]
    f(a,b,c,d)
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  cout << n*(n+1)/2 << endl;
}

### FIXED CODE ###

N = int(input())
print(N*(N+1)//2)
N,K = map(int,input().split(" "))
array = list(map(int,input().split(" ")))

minus = 0
while array[minus] < 0 and minus < N:minus += 1
plus = N-minus

first,last = max(minus-K,0),min(minus,N-K)

ans = array[N-1]- array[0]

for i in range(first,last+1):
    m_dist, p_dist = array[i], array[K-1+i]
    if m_dist*p_dist <=0:
        dist_i = min(abs(m_dist),abs(p_dist))*2+max(abs(m_dist),p_dist)
    else:
        dist_i = max(abs(m_dist),abs(p_dist))
    ans = min(ans,dist_i)

print(ans)

### FIXED CODE ###

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

minus = 0
while minus < N and array[minus]<0:
    minus += 1

first,last = max(minus-K,0),min(minus,N-K)

ans = 2*(array[N-1]- array[0])

for i in range(first,last+1):
    m_dist, p_dist = array[i], array[K-1+i]
    if m_dist*p_dist <=0:
        dist_i = min(abs(m_dist),abs(p_dist))*2+max(abs(m_dist),p_dist)
    else:
        dist_i = max(abs(m_dist),abs(p_dist))
    ans = min(ans,dist_i)

print(ans)
INF = float('inf')
H,W = map(int,input().split())
s = [input() for _ in range(H)]
cost = [[INF]*W for _ in range(H)]
cost[0][0] = 1

def bfs(h,w):
    for dh,dw in [[1,0],[-1,0],[0,1],[0,-1]]:
        if 0<=h+dh<H and 0<=w+dw<W:
            if s[h+dh][w+dw] == '.' and cost[h+dh][w+dw] > cost[h][w]+1:
                cost[h+dh][w+dw] = cost[h][w]+1
                bfs(h+dh,w+dw)

bfs(0,0)

count = 0
for i in range(H):
    for j in range(W):
        if s[i][j] == '#':
            count += 1
 
ans = -1
if d[H-1][W-1] != INF:
    ans = H*W-count-d[-1][-1]
print(ans)

### FIXED CODE ###

import queue
H,W = map(int,input().split())
maze = [0]*H
for i in range(H):
    maze[i] = input()
inf = float('inf')
d = [[inf for i in range(W)] for i in range(H)]
dx = [1,0,-1,0]
dy = [0,1,0,-1]


def bfs():
    que = queue.Queue()
    que.put((0,0))
    d[0][0] = 0
    while que.qsize():
        p = que.get()
        if p == (H-1,W-1):
            break
        for i in range(4):
            nx = p[0]+dx[i]
            ny = p[1]+dy[i]
            if 0 <= nx and nx <= H-1 and 0 <= ny and ny <= W-1 \
            and maze[nx][ny] != '#' and d[nx][ny] == inf:
                d[nx][ny] = d[p[0]][p[1]] + 1
                que.put((nx,ny))

bfs()

count = 0
for i in range(H):
    for j in range(W):
        if maze[i][j] == '#':
            count += 1

ans = -1
if d[H-1][W-1] != inf:
    ans = H*W-count-1-d[H-1][W-1]
print(ans)
H, W = map(int, input().split())
S = [input() for _ in range(H)]
M = [[float('inf') for _ in range(W)] for _ in range(H)]


def dfs(x, y, c):
    cc = float('inf')
    for xx, yy in [(x + 1, y), (x, y + 1), (x - 1, y), (x, y - 1)]:
        if (H, W) == (yy + 1, xx + 1):
            return c + 1
        if 0 <= yy < H and 0 <= xx < W and S[yy][xx] == '.' and \
                (M[yy][xx] > c + 1):
            M[yy][xx] = c + 1
            cc = min(cc, dfs(xx, yy, c + 1))
    return cc


def main():
    ans = 0
    for i in range(H):
        ans += S[i].count('.')
    c = dfs(0, 0, 1)
    if c == float('inf'):
        print(-1)
    else:
        print(ans - c)


main()


### FIXED CODE ###

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


def bfs():
    q = [(0, 0)]
    nq = []
    m = []
    c = 1
    while len(q) > 0:
        while len(q) > 0:
            x, y = q.pop(0)
            for xx, yy in [(x + 1, y), (x, y + 1), (x - 1, y), (x, y - 1)]:
                if (H, W) == (yy + 1, xx + 1):
                    return c + 1
                if 0 <= yy < H and 0 <= xx < W and S[yy][xx] == '.' and \
                        (xx, yy) not in m:
                    m.append((xx, yy))
                    nq.append((xx, yy))
        q = nq
        nq = []
        c += 1
    return -1


def main():
    ans = 0
    for i in range(H):
        ans += S[i].count('.')
    c = bfs()
    if c == -1:
        print(-1)
    else:
        print(ans - c)


main()
b=int(input())
a=[for i in range(b)]
r=int(input())
c=[for i in range(r)]
cnt=0
for i in range(b):
  cnt=max(cnt,a.count(a[i])-c.count(a[i]))
print(cnt)

### FIXED CODE ###

b=int(input())
a=[input() for i in range(b)]
r=int(input())
c=[input() for i in range(r)]
cnt=0
for i in range(b):
  cnt=max(cnt,a.count(a[i])-c.count(a[i]))
print(cnt)