Harryxun/stf_run huggingface dataset:
h,w,m=map(int,input().split())
bomb=[list(map(int,input().split())) for _ in range(m)]
a=[0 for i in range(h+1)]
b=[0 for _ in range(w+1)]
for i in range(m):
    a[bomb[i][0]]+=1
    b[bomb[i][1]]+=1
am=max(a)
bm=max(b)
aa=set([i for i, x in enumerate(a) if x==am])
bb=set([i for i, x in enumerate(b) if x==bm])
c=[0 for i in range(m)]
d=[0 for i in range(m)]
for x in bomb:
        c[x[0]-1]+=1
        d[x[1]-1]+=1
cm=max(c)
dm=max(d)
aaa=len(aa)
bbb=len(bb)
if cm<bbb or dm<aaa:
    print(am+bm)
else:
    print(am+bm-1)

### FIXED CODE ###

h,w,m=map(int,input().split())
bomb=[list(map(int,input().split())) for _ in range(m)] #bombの位置
a=[0 for i in range(h+1)] #各行のbombの個数
b=[0 for _ in range(w+1)] #各列のbombの個数
for i in range(m):
    a[bomb[i][0]]+=1
    b[bomb[i][1]]+=1
am=max(a) #１行にあるbombの最大値
bm=max(b) #１列にあるbombの最大値
hmax=[0]*(h+1) #最大値をとるh全部
wmax=[0]*(w+1) #最大値をとるw全部
for i in range(h+1):
    if am==a[i]:
        hmax[i]+=1
for i in range(w+1):
    if bm==b[i]:
        wmax[i]+=1
ans=am+bm #基本解
k=sum(hmax)*sum(wmax)
if k>m: #鳩ノ巣原理
    print(ans)
    exit()
for i in bomb:
    if hmax[i[0]]==1 and wmax[i[1]]==1:
        k-=1
if k==0:
    print(ans-1)
else:
    print(ans)
import numpy as np
import math
from decimal import *
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return list(map(int, input().split()))
def getNumpy():
    return np.array(list(map(int, input().split())), dtype='int64')

def factorization(n):
    d = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            d.append({i, cnt})

    if temp!=1:
        d.append({temp, 1})

    if d==[]:
        d.append({n, 1})

    return d

def main():
    N = int(input())
    d = factorization(N)
    count = 0

    for v in d.values():
        i = 1
        while(v >= i):
            v -= i
            i += 1
            count += 1
        
    print(count)


main()

### FIXED CODE ###

import numpy as np
import math
from decimal import *
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return list(map(int, input().split()))
def getNumpy():
    return np.array(list(map(int, input().split())), dtype='int64')

def factorization(n):
    d = {}
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            d.update({i: cnt})

    if temp!=1:
        d.update({temp: 1})

    if d==[]:
        d.update({n:1})

    return d

def main():
    N = int(input())
    d = factorization(N)
    count = 0

    for v in d.values():
        i = 1
        while(v >= i):
            v -= i
            i += 1
            count += 1
        
    print(count)


main()
import math

a, b= map(int, input().split())
def lcm(x,y):
    return (x*y/math.gcd(x,y))

print(int(lcm(a,b)))


### FIXED CODE ###

import fractions as fr

a, b= map(int, input().split())
def lcm(x,y):
    return (x*y/fr.gcd(x,y))

print(int(lcm(a,b)))
m = nm[1]
all_city = list()
for i in range(m):
    py = list(map(int, input().split()))
    py.append(i)
    all_city.append(py)
ac_list = copy.deepcopy(all_city)
ac_list.sort()
ac_dict = {}
a = 0
b = 0
for i in range(m):
    if ac_list[i][0] == a:
        b += 1
    else:
        a += 1
        b = 1
    ac_dict[ac_list[i][2]] = str(str(a).zfill(6) + str(b).zfill(6))
for i in range(m):
    print(ac_dict.get(all_city[i][2]))

### FIXED CODE ###

import copy
nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]
all_city = list()
for i in range(m):
    py = list(map(int, input().split()))
    py.append(i)
    all_city.append(py)
ac_list = copy.deepcopy(all_city)
ac_list.sort()
ac_dict = {}
a = 0
b = 0
for i in range(m):
    if ac_list[i][0] == a:
        b += 1
    else:
        a = ac_list[i][0]
        b = 1
    ac_dict[ac_list[i][2]] = str(str(a).zfill(6) + str(b).zfill(6))
for i in range(m):
    print(ac_dict.get(all_city[i][2]))
n, k = map(int, input().split())
d = list(map(int, input().split()))

ok = sorted(list(set(d) ^ {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}))

ans = ''
for i in range(len(str(n))):
    num = int(str(n)[i])
    ans += str(min([j for j in ok if j >= num]))

print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
d = set(input().split())

while set(list(str(n))) & d != set():
    n += 1

print(n)
n = int(input())
a = []
for i in range(n):
    s, p = input().split()
    a.append((s, -int(p), i))
a.sort()

for _, _, i in a:
    print(i + 1)

### FIXED CODE ###

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

print((3 * A + P) // 2)
N = int(input())
H_inp = input()
H = H_inp.split(" ")
for i in range(N):
    H[i] = int(H[i])
 

ans   = 0
count = 0


for j in range(1,N):
    if N == 1:
       break
 
    if H[j] >= H[j+1]:
        count += 1
    else:
        if count > ans:
            ans   = count
            count = 0
 
    if j == N-1:
        if count > ans:
            ans   = count
        break

print(ans)

### FIXED CODE ###

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

ans   = 0
count = 0


for j in range(N):
    if N == 1:
       break
 
    if H[j] >= H[j+1]:
        count += 1
    else:
        ans   = max(count, ans)
        count = 0
 
    if j == N-2:
        if count > ans:
            ans   = count
        break

print(ans)
A,B = map(int.input().split)

if A > 9 or B > 9:
	print(-1)
else:
	print(A*B)

### FIXED CODE ###

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

if A > 9 or B > 9:
	print(-1)
else:
	print(A*B)
n,a,b=[int(x) for x in input().split()]
ans=0
for i in rabge(n):
  t=0
  while i:
    t+=i%10
    i/=10
  if a<=t and t<=b:ans+=t
print(ans)

### FIXED CODE ###

n,a,b=[int(x) for x in input().split()]
ans=0
for i in range(n+1):
  j,t=i,0
  while j:
    t+=j%10
    j=j//10
  if a<=t and t<=b:ans+=i
print(ans)
# -*- coding: utf-8 -*-


def partition(A, p, r):
    x = A[r]
    i = p 
    for j in range(1, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i], A[r] = A[r], A[i]
    return i 


def main():
    n = int(input())
    A = [int(e) for e in input().split()]
    p = 0
    r = len(A) - 1
    idx = partition(A, p, r)
    A[idx] = "[%s]" % A[idx]
    return " ".join(A)

main()

### FIXED CODE ###

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


def partition(a, p, r):
    x = ns[r]
    i = p - 1
    for j in range(p, r):
        if ns[j] <= x:
            i += 1
            ns[i], ns[j] = ns[j], ns[i]
    ns[i + 1], ns[r] = ns[r], ns[i + 1]
    return i + 1, ns


if __name__ == '__main__':
    n = int(input())
    ns = [int(e) for e in input().split()]
    # n = 12
    # ns = [13, 19, 9, 5, 12, 8, 7, 4, 21, 2, 6, 11]
    r = len(ns) - 1
    idx, ns = partition(ns, 0, r)
    ns = [str(n) for n in ns]
    ns[idx] = '[{}]'.format(ns[idx])
    print(" ".join(ns))
a=list(map(lambda x:x,input(),split()))
if(a[1]>a[0]):
  print(str(a[0])*a[1])
else:
  print(str(a[1])*a[0])

### FIXED CODE ###

a=list(map(lambda x:x,input().split()))
if(a[1]>a[0]):
  print(a[0]*int(a[1]))
else:
  print(a[1]*int(a[0]))
num v= input("")
sum1 = num + num^2 + num^3

### FIXED CODE ###

a = int(input())
print(a+a**2+a**3)
if __name__=="__main__":
    x, a ,b = input().split()
    if b - a <= 0:
        print("delicious")
    elif b - a <= x:
        print("safe")
    else:
        print("dangerous")


### FIXED CODE ###

if __name__=="__main__":
    x, a ,b = map(int, input().split())
    if b - a <= 0:
        print("delicious")
    elif b - a <= x:
        print("safe")
    else:
        print("dangerous")
S = int(input())
W = int(input())
if S >= W : print("safe")
else: print("unsafe")

### FIXED CODE ###

S, W = map(int,input().split())
if S <= W :
  print("unsafe")
else:
  print("safe")
N=int(input())
A=list(map(int,input().split()))
def quick_sort(a):
    if len(a)<= 1:
        return a
    else:
        b=[]
        c=[]
        for i in range(1, len(a)):
            if a[i]<a[0]:
                b.append(a[i])
            else:
                c.append(a[i])
        return quick_sort(b)+[a[0]]+quick_sort(c)
def abs(x):
    if x>=0:
        return x
    else:
        return x*(-1)
B=[0]*N
for i in range(N):
  B[i]=A[i]-i-1
C=quick_sort(B)
if N%2==0:
  b=(C[N//2]+C[N//2-1])//2
else:
  b=C[N//2+1]
sad=0
for j in range(N):
  sad=sad+abs(C[j]-b)
print(sad)


### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
B=[]
for i in range(N):
  B.append(A[i]-i-1)
B.sort()
if N%2==0:
  b=(B[N//2]+B[N//2-1])//2
else:
  b=B[N//2]
sad=0
for j in range(N):
  sad=sad+abs(B[j]-b)
print(sad)
s = input()

head = int(s[:2])
tail = int(s[2:])

if 0 < head <= 12 and 0 < tail <= 12:
  print("AMBIGUOUS")

elif 0 < head <= 12:
  print("MMYY")
elif 0 < tail <= 12:
  print("YYMM")
elif :
  print("NA")


### FIXED CODE ###

s = input()

head = int(s[:2])
tail = int(s[2:])

if 0 < head <= 12 and 0 < tail <= 12:
  print("AMBIGUOUS")

elif 0 < head <= 12:
  print("MMYY")

elif 0 < tail <= 12:
  print("YYMM")

else :
  print("NA")
N, X = map(int, input().split(' '))
height = [1]

for i in range(N):
	height.append(height[-1]*2 + 3)

def patty(N,X):
	if N==1:
		l = [0,1,2,3,3]
		return l[X-1]
	elif N>=2:
		if X<(height[N]+1)/2:
			return patty(N-1,X-1)
		elif X==(height[N]+1)/2:
			return patty(N-1,height[N-1]) + 1
		elif X>(height[N]+1)/2:
			return patty(N-1,height[N-1]) + 1 + patty(N-1,X-2-height[N-1])

print(patty(N,X))


### FIXED CODE ###

N, X = map(int, input().split(' '))
height = [1]

for i in range(N):
	height.append(height[-1]*2 + 3)

def patty(N,X):
	if N==1:
		l = [0,1,2,3,3]
		return l[X-1]
	elif N>=2:
		if X == 1:
			return 0
		elif X <= height[N-1]+1:
			return patty(N-1,X-1)
		elif X == height[N-1]+2:
			return patty(N-1,height[N-1])+1
		elif X == height[N]:
			return patty(N-1,height[N-1])*2+1
		elif X >= height[N-1]+3:
			return patty(N-1,height[N-1])+1+ patty(N-1,X-2-height[N-1])

print(patty(N,X))
t = []
index = {}
for n in range(N):
    si, ti = input().split()
    ti = int(ti)
    index[si] = n
    t.append(ti)

X = input()

ans = 0
for i in range(index[X]+1, N):
    ans += t[i]

print(ans)

### FIXED CODE ###

N = int(input())
t = []
index = {}
for n in range(N):
    si, ti = input().split()
    ti = int(ti)
    index[si] = n
    t.append(ti)

X = input()

ans = 0
for i in range(index[X]+1, N):
    ans += t[i]

print(ans)
#include <bits/stdc++.h>
using namespace std;

int main() {
  int n, m;
  cin >> n >> m;

  if (n>=2 && m>=2) {
      cout << n*m - (n-2)*2 - (m-2)*2 - 4 << endl;
  }
  else if (n==1 && m==1) {
      cout << 1 << endl;
  }
  else if (n==1 && m>=2) {
      cout << m-2 << endl;
  }
  else {
      cout << n-2 << endl;
  }
  return 0;
}

### FIXED CODE ###

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

if n>=2 and m>=2:
    print(n*m - (n-2)*2 - (m-2)*2 - 4)
elif n==1 and m==1:
    print(1)
elif n==1 and m>=2:
    print(m-2)
else:
    print(n-2)
# coding: utf-8

n = input()
A = []
for i in xrange(n):
    A.append( map(int, raw_input().split()) )

Max = -1
Maxidx = -1
for i in xrange(n):
    if Max < A[i][1]:
        Max = A[i][1]
        Maxidx = i
    elif Max = A[i][1] and A[Maxidx][0] > A[i][0]:
        Maxidx = i

print A[Maxidx][0], A[Maxidx][1]

### FIXED CODE ###

# coding: utf-8

n = input()
A = []
for i in xrange(n):
    A.append( map(int, raw_input().split()) )

Max = -1
Maxidx = -1
for i in xrange(n):
    if Max < A[i][1]:
        Max = A[i][1]
        Maxidx = i
    elif Max == A[i][1] and A[Maxidx][0] > A[i][0]:
        Maxidx = i

print A[Maxidx][0], A[Maxidx][1]
import sys
sys.setrecursionlimit(10000)
N,M = map(int,input().split())
graph = [[] for i in range(10**5 + 10)]
dp = [-1 for i in range(10**5 + 10)]

for i in range(M):
    x,y = map(int,input().split())
    graph[x-1].append(y-1)
    
def rec(v):
    if dp[v] != -1:
        return dp[v]
    tmp = 0
    for x in graph[v]:
        r = rec(x)+1
        if tmp < r:
            tmp = r
    dp[v] = tmp
    return dp[v]

result = 0
for i in range(N):
    r = rec(i)
    result = r if r>result else result
print(result)

### FIXED CODE ###

import sys
sys.setrecursionlimit(100000)
N,M = map(int,input().split())
graph = [[] for i in range(10**5 + 10)]
dp = [-1 for i in range(10**5 + 10)]

for i in range(M):
    x,y = map(int,input().split())
    graph[x-1].append(y-1)
    
def rec(v):
    if dp[v] != -1:
        return dp[v]
    tmp = 0
    for x in graph[v]:
        r = rec(x)+1
        if tmp < r:
            tmp = r
    dp[v] = tmp
    return dp[v]

result = 0
for i in range(N):
    r = rec(i)
    result = r if r>result else result
print(result)
import math

    
def main():
    Input = [input() for i in range(1)]
    N = int(Input[0])
    x = math.sqrt(N)
    if x.is_integer():
        print(int(x+N/x-2))
    else:
        while x >= 1:
            x = math.floor(x)-1
            y = N/x
            if y.is_integer():
                print(int(x+y-2))
                break

        
        
if __name__ == "__main__":
    main()
    


### FIXED CODE ###

import math

def main():
    Input = [input() for i in range(1)]
    N = int(Input[0])
    x = math.sqrt(N)
    if x.is_integer():
        print(int(x+N/x-2))
    else:
        while x >= 1:
            x = math.ceil(x)-1
            y = N/x
            if y.is_integer():
                print(int(x+y-2))
                break

        
        
if __name__ == "__main__":
    main()
#!/usr/bin/env python3

import sys

def read_int_list(sep = " "):
    return [int(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    return
    print(*args, **kwargs)


def choose(a, b, mod):
    numer, denomi = 1, 1 
    for i in range(0, b):
        denomi = (denomi * (i + 1)) % mod
        numer = ((a - i) * numer) % mod
    return (numer * pow(denomi, mod - 2, mod)) % mod


def main():
    mod = 1000_000_007
    n, a, b = read_int_list()
    ans = pow(2, n, mod)
    ans -= 1  # case for zero flowers
    ans -= choose(n, a, mod)
    ans -= choose(n, b, mod)
    if ans < 0:
        ans += mod
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

#!/usr/bin/env python3

import sys

def read_int_list(sep = " "):
    return [int(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    return
    print(*args, **kwargs)


def choose(a, b, mod):
    numer, denomi = 1, 1 
    for i in range(0, b):
        denomi = (denomi * (i + 1)) % mod
        numer = ((a - i) * numer) % mod
    return (numer * pow(denomi, mod - 2, mod)) % mod


def main():
    mod = 1000000007
    n, a, b = read_int_list()
    ans = pow(2, n, mod)
    ans = (ans - 1) % mod  # case for zero flowers
    ans = (ans - choose(n, a, mod)) % mod
    ans = (ans - choose(n, b, mod)) % mod
    print(ans)


if __name__ == "__main__":
    main()
n = int(input())
a = []
for i in range(n):
    s = int(input())
    a.append(s)
a.sort()
i = 0
cnt = 0
while i < n:
    j = i+1
    chk = 0
    while a[i] == a[j]:
        chk += 1
        j += 1
        if j >= n:
            break
    if chk%2 == 1:
        cnt += 1 
    i = j
print(cnt)

### FIXED CODE ###

n = int(input())
a = []
for i in range(n):
    s = int(input())
    a.append(s)
a.sort()
i = 0
cnt = 0
while i < n:
    j = i+1
    chk = 1
    if j >= n:
        cnt += 1 
        break
    while a[i] == a[j]:
        chk += 1
        j += 1
        if j >= n:
            break
    if chk%2 == 1:
        cnt += 1 
    i = j
print(cnt)
N, K = map(int, input().split())
A = list(map(int, input().split()))
m = 10**9+7
pos = [*filter(lambda x: x>0, A)]
neg = [*filter(lambda x: x<0, A)]
pos.sort(reverse=True)
neg.sort()
if len(pos) + len(neg) < K:
    print(0)
    exit()

ans = 1
i,j = 0,0# 使った数
while i+j < K:
    flag = True
    if i == len(pos):
        flag = False
    elif j == len(neg):
        flag = True
    elif pos[i] >= -neg[j]:
        flag = True
    else:
        flag = False

    if flag:
        ans = ans * pos[i] % m
        i += 1
    else:
        ans = ans * neg[j] % m
        j += 1
# print(i,j)
if j % 2 == 0 or N==K:
    print(ans)
elif len(pos) == 0:
    ans = 1
    for i in range(K):
        ans = ans * neg[len(neg)-1-i] % m
    print(ans)
else:
    flag2 = True
    if i == len(pos):
        flag2 = False
    elif j == len(neg):
        flag2 = True
    elif pos[i-1]*pos[i] >= neg[j-1]*neg[j]:
        flag2 = True
    else:
        exit(1)
        flag2 = False

    if flag2:
        ans = ans * pow(neg[j-1],m-2,m) % m
        ans = ans * pos[i] % m
    else:
        ans = ans * pow(pos[i-1],m-2,m) % m
        ans = ans * neg[j] % m
    print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
A = list(map(int, input().split()))
m = 10**9+7
pos = [*filter(lambda x: x>=0, A)]
neg = [*filter(lambda x: x<0, A)]
pos.sort(reverse=True)
neg.sort()

ans = 1
i,j = 0,0# 使った数
while i+j < K:
    flag = True
    if i == len(pos):
        flag = False
    elif j == len(neg):
        flag = True
    elif pos[i] >= -neg[j]:
        flag = True
    else:
        flag = False

    if flag:
        ans = ans * pos[i] % m
        i += 1
    else:
        ans = ans * neg[j] % m
        j += 1

if j % 2 == 0 or N==K:
    print(ans)
elif len(pos) == 0:
    ans = 1
    for i in range(K):
        ans = ans * neg[len(neg)-1-i] % m
    print(ans)
else:
    flag2 = True
    if i == 0:
        flag2 = True
    elif j == 0:
        flag2 = False
    elif i == len(pos):
        flag2 = False
    elif j == len(neg):
        flag2 = True
    elif pos[i-1]*pos[i] > neg[j-1]*neg[j]:# = を抜いた
        flag2 = True
    else:
        flag2 = False

    if flag2:
        ans = ans * pow(neg[j-1],m-2,m) % m
        ans = ans * pos[i] % m
    else:
        ans = ans * pow(pos[i-1],m-2,m) % m
        ans = ans * neg[j] % m
    print(ans)
n,k,q=map(int,input().split())
a=[(input()) for l in range(q)]
if q-k<0:
    for i in range(n):
        print('Yes')
else:
    c = collections.Counter(a)
    for i in range(n):
        if c[str(i)]>q-k:
            print('Yes')
        else:
            print('No')

### FIXED CODE ###

n,k,q=map(int,input().split())
a=[(input()) for l in range(q)]
#if q-k<0:
 #   for i in range(n):
  #      print('Yes')
#else:
import collections
c = collections.Counter(a)
for i in range(n):
    #print(k-c[str(i+1)])
    if q-c[str(i+1)]<k:
        print('Yes')
    else:
        print('No')
n = int(input())
num = list(map(int, input().split()))
cnt = 0
for i in range(1, n) :
  if num[i - 1] > num[i] & num[i] > num[i + 1] :
    cnt += 1
  elif num[i - 1] < num[i] & num[i] < num[i + 1] :
    cnt += 1
print(cnt)

### FIXED CODE ###

n = int(input())
num = list(map(int, input().split()))
cnt = 0
for i in range(1, n - 1) :
  if num[i - 1] > num[i] & num[i] > num[i + 1] :
    cnt += 1
  elif num[i - 1] < num[i] & num[i] < num[i + 1] :
    cnt += 1
print(cnt)
# ABC142D - Disjoint Set of Common Divisors
from fractions import gcd


def divisors(n: int) -> set:
    div = set()
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            div.add(i), div.add(n // i)
    return div


def get_primes(n: int) -> set:
    # return a list of primes <= n
    n += 1
    sieve = [1] * n
    for i in range(3, int(n ** 0.5) + 1, 2):
        if sieve[i]:
            sieve[i * i :: 2 * i] = [0] * ((n - i * i - 1) // (2 * i) + 1)
    return {2} | {i for i in range(3, n, 2) if sieve[i]}


def main():
    A, B = map(int, input().split())
    g = gcd(A, B)
    ans = len(divisors(g) & get_primes(g)) + 1
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

# ABC142D - Disjoint Set of Common Divisors
def divisors(n: int) -> set:
    div = set()
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            div.add(i), div.add(n // i)
    return div


def main():
    A, B = map(int, input().split())
    divs = sorted(divisors(A) & divisors(B))
    divs.pop(0)
    groups = set()
    for i in divs:
        if all(i % x for x in groups):
            groups.add(i)
    ans = len(groups) + 1
    print(ans)


if __name__ == "__main__":
    main()
S = input().replace('+x', '+1x').replace('^', '**').replace('x', '*1*(x)')[1:]
for i in range(2000, -2001, -1):
    if i == 0: continue

    T = S.replace('x', str(i))
    #print(T, eval(T))
    if eval(T) == 0:
        print('(x{:+})'.format(-i), end='')
else:
    print()



### FIXED CODE ###

S = input().replace('+x', '+1x').replace('-x', '-1x').replace('^', '**').replace('x', '*1*(x)')[1:]
for i in range(2000, -2001, -1):
    if i == 0: continue

    T = S.replace('x', str(i))
    #print(T, eval(T))
    if eval(T) == 0:
        print('(x{:+})'.format(-i), end='')
else:
    print()
n = int(input())
data1 = [list(map(int,input().split())) for _ in range(n)]
data2 = [list(map(int,input().split())) for _ in range(n)]
ans = []
trans = -1
for i in range(2**10):
    S = [0]*10
    l = 0
    for j in range(10):
        for k in range(n):
            S[k] += data1[k][j]*((i>>j)&1)
    for j in range(n):
        l += data2[j][S[j]]
    ans.append(l)
    if not i:
        trans = l
ans.sort()
print(ans[-1] if ans[-1] != trans else ans[-2])

### FIXED CODE ###

n = int(input())
data1 = [list(map(int,input().split())) for _ in range(n)]
data2 = [list(map(int,input().split())) for _ in range(n)]
ans = []
trans = -1
for i in range(2**10):
    S = [0]*n
    l = 0
    for j in range(10):
        for k in range(n):
            S[k] += data1[k][j]*((i>>j)&1)
    for j in range(n):
        l += data2[j][S[j]]
    ans.append(l)
    if not i:
        trans = l
ans.sort()
print(ans[-1] if ans[-1] != trans else ans[-2])
n,m = map(int, input().split())
X = [int(x) for x in input().split()]
Y = [int(y) for y in input().split()]
mod = 10**9+7

Xd = []
for i in range(n-1):
    Xd.append(X[i+1]-X[i])
    
Yd = []
for i in range(m-1):
    Yd.append(Y[i+1]-Y[i])
    
Xd[1] = 2*Xd[0] + 2*Xd[1]
for i in range(n-3):
    Xd[i+2] = 2*Xd[i+1] - Xd[i] + (i+3)*Xd[i+2]
    Xd[i+2] %= mod
    
Yd[1] = 2*Yd[0] + 2*Yd[1]
for i in range(m-3):
    Yd[i+2] = 2*Yd[i+1] - Yd[i] + (i+3)*Yd[i+2]
    Yd[i+2] %= mod
    
print(Xd[-1]*Yd[-1]%mod)

### FIXED CODE ###

n,m = map(int, input().split())
X = [int(x) for x in input().split()]
Y = [int(y) for y in input().split()]
mod = 10**9+7

Xd = []
for i in range(n-1):
    Xd.append(X[i+1]-X[i])
    
Yd = []
for i in range(m-1):
    Yd.append(Y[i+1]-Y[i])
    
if n > 2:
    Xd[1] = 2*Xd[0] + 2*Xd[1]
    for i in range(n-3):
        Xd[i+2] = 2*Xd[i+1] - Xd[i] + (i+3)*Xd[i+2]
        Xd[i+2] %= mod
        
if m > 2:
    Yd[1] = 2*Yd[0] + 2*Yd[1]
    for i in range(m-3):
        Yd[i+2] = 2*Yd[i+1] - Yd[i] + (i+3)*Yd[i+2]
        Yd[i+2] %= mod
    
print(Xd[-1]*Yd[-1]%mod)
input()

data = input.split()

data.reverse()
[print(x, end=' ') for x in data]
print()

### FIXED CODE ###

input()
data = input().split()
data.reverse()
print(' '.join(data))
import math
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
if N > 1:
    mini = x[1] - x[0]
    if mini > abs(X - x[0]) and abs(X - x[0]) != 0:
        mini = abs(X - x[0])
elif N == 1:
    mini = abs(x[0] - X)
for i in range(1, N):
    if mini > x[i] - x[i - 1]:
        mini = x[i] - x[i - 1]
    if mini> abs(X - x[i]) and abs(X - x[i]) != 0:
        mini = abs(X - x[i])
    if (x[i] - x[i - 1]) % mini != 0:
        #break
        mini = math.gcd(mini, x[i] - x[i - 1])
    if abs(X - x[i]) % mini != 0:
        #break
        mini = math.gcd(mini, X - x[i])
        

print(mini)


### FIXED CODE ###

import fractions
N, X = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
if N > 1:
    mini = x[1] - x[0]
    if mini > abs(X - x[0]) and abs(X - x[0]) != 0:
        mini = abs(X - x[0])
elif N == 1:
    mini = abs(x[0] - X)
for i in range(1, N):
    if mini > x[i] - x[i - 1]:
        mini = x[i] - x[i - 1]
    if mini> abs(X - x[i]) and abs(X - x[i]) != 0:
        mini = abs(X - x[i])
    if (x[i] - x[i - 1]) % mini != 0:
        #break
        mini = fractions.gcd(mini, x[i] - x[i - 1])
    if abs(X - x[i]) % mini != 0:
        #break
        mini = fractions.gcd(mini, X - x[i])
        

print(mini)
import math
N,D =map(int,input().split())

x = D * 2 + 1

pre_answer = N / X
print(math.ceil(pre_answer))


### FIXED CODE ###

import math
N,D =map(int,input().split())

X = D * 2 + 1

pre_answer = N / X
print(math.ceil(pre_answer))