Harryxun/stf_run huggingface dataset:
import sys
input = sys.stdin.readline
n,k = map(int,input().split())
edge = [[] for i in range(n)]
alledge = []
for i in range(n-1):
    a,b = map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
    alledge.append([a-1,b-1])
if n==2:
    print(0)
    exit()


def f(x):
    #c +=1
    for e in edge[x]:
        #if e != y:
            #if c > d:
            #    used[e] = 1
        f(e)


if k % 2 == 0:
    d = k//2
    res = []
    for i in range(n):
        used = [0]*n
        f(i,-1,0)
        res.append(sum(used))
    print(min(res))
else:
    d = (k-1)//2
    res = []
    for e1 in alledge:
        used = [0]*n
        f(e1[0])
        f(e1[1])
        res.append(sum(used))
    print(min(res))


### FIXED CODE ###

import sys
#input = sys.stdin.readline
n,k = map(int,input().split())
edge = [[] for i in range(n)]
alledge = []
for i in range(n-1):
    a,b = map(int,input().split())
    edge[a-1].append(b-1)
    edge[b-1].append(a-1)
    alledge.append((a-1,b-1))

def f(x,y,c):
    global tmp
    c += 1
    for e in edge[x]:
        if e == y:
            continue
        if c > d:
            tmp +=1
        f(e,x,c)

sys.setrecursionlimit(4100000)

if k % 2 == 0:
    d = k//2
    ass = 2001
    for i in range(n):
        tmp = 0
        f(i,-1,0)
        ass = min(ass,tmp)
    print(ass)
else:
    d = (k-1)//2
    ass = 2001
    for e1 in alledge:
        tmp = 0
        f(e1[0],e1[1],0)
        f(e1[1],e1[0],0)
        ass = min(ass,tmp)
    print(ass)
n[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
 
print(n[k-1])

### FIXED CODE ###

number = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
 
print(number[int(input())-1])
n = int(input())
record =  [ [ [0 for r in range(10)] for f in range(3) ] for b in range(4)]
for i in range(n):
    b, f, r, v = [int(a) for a in input().split(" ")]
    record[b - 1][f - 1][r - 1] += v
for b in range(4):
    for f in record[b]:
        print( " ".join( [str(x) for x in f] ) )
    if b != 3:
        print("#" * 20)
        

### FIXED CODE ###

n = int(input())
record = [ [ [0 for r in range(10)] for f in range(3)] for b in range(4)]
for _ in range(n):
    b,f,r,v = [int(i) for i in input().split(" ")]
    record[b - 1][f - 1][r - 1] += v
for b1 in range(4):
    for f in record[b1]:
        print(" "+" ".join([str(x) for x in f]))
    if b1 != 3:
        print("#" * 20)
import sys
input() = sys.stdin.readline().rstrip()

h, w, k = map(int, input().split())
s = []
for i in range(h):
    s.append(list(map(int, input())))

ans = h + w - 2
for i in range(1<<(h-1)):
    l = []
    tmp = s[0]
    for j in range(h-1):
        if i >> j & 1:
            tmp = [tmp[m] + s[j+1][m] for m in range(w)]
        else:
            l.append(tmp)
            tmp = s[j+1]
    l.append(tmp)
    c = [0] * len(l)
    cnt = 0
    flag = False
    j = 0
    while j < w:
        for m in range(len(l)):
            c[m] += l[m][j]
            if c[m] > k:
                flag = True
        if flag:
            c = [0] * len(l)
            cnt += 1
            flag = False
            j -= 1
        j += 1
    ans = min(ans, len(l) + cnt - 1)

print(ans)

### FIXED CODE ###

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

res = float('inf')
for i in range(2**(H-1)):
    c = bin(i).count('1')
    cnt = c
    sum_l = [0] * (c+1)
    j = 0
    flag = True
    while j < W:
        tmp = sum_l.copy()
        pos = 0
        for k in range(H):
            if S[k][j] == '1':
                tmp[pos] += 1
            if (i >> k) & 1:
                pos += 1
        if max(tmp) <= K:
            sum_l = tmp.copy()
            j += 1
            flag = False
        else:
            if flag:
                cnt = float('inf')
                break
            cnt += 1
            flag = True
            sum_l = [0] * (c+1)

    res = min(res, cnt)

print(res)
from sys import stdin
n = int(stdin.readline().rstrip())
def num(n):
    if n%2 == 0:
        return num(n//(-2)) + "0"
    else:
        return num(n//(-2)) + "1"

if n == 0:
    print(0)
    exit()

print(num(n))

### FIXED CODE ###

from sys import stdin
n = int(stdin.readline().rstrip())
def num(n):
    if n == 0:
        return ""
    if n%2 == 0:
        return num(n//(-2)) + "0"
    else:
        return num((n-1)//(-2)) + "1"
if n == 0:
    print(0)
    exit()
print(num(n))
import sys

#N,Q = list(map(int,input().split()))
N,Q = [int(i) for i in sys.stdin.readline().split()]
G=[]
for i in range(N):
    G.append([])

for i in range(N-1):
    #a,b = list(map(int,input().split()))
    a,b = [int(j) for j in sys.stdin.readline().split()]
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

p=[0]*Q
x=[0]*Q
c=[0]*N

for i in range(Q):
    #p,x = list(map(int,input().split()))
    p,x = [int(j) for j in sys.stdin.readline().split()]
    p-=1
    c[p] += x

stack=deque([0])
parent = [-1]*N

while(stack):
    v = stack.pop()
    for u in G[v]:
        if u!=parent[v]:
            c[u]+=c[v]
            parent[u]=v
            stack.append(u)


ans = ' '.join([str(x) for x in c])

print(ans)

### FIXED CODE ###

'''
pythonの再帰は10^5timesですら厳しい
import sys
sys.setrecursionlimit(10000000)

def dfs(v,p,G,c):
    for u in G[v]:
        if u!=p:
            c[u]+=c[v]
            dfs(u,v,G,c) 
'''
from collections import deque

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

G=[]
for i in range(N):
    G.append([])
for i in range(N-1):
    a,b = list(map(int,input().split()))
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

p=[0]*Q
x=[0]*Q
c=[0]*N
for i in range(Q):
    p,x = list(map(int,input().split()))
    p-=1
    c[p] += x

stack=deque([0])
parent = [-1]*N

while(stack):
    v = stack.pop()
    for u in G[v]:
        if u!=parent[v]:
            c[u]+=c[v]
            parent[u]=v
            stack.appendleft(u)


ans = ' '.join([str(x) for x in c])

print(ans)
# -*- coding: utf-8 -*-

class Node(object):
    def __init__(self, key, prev=None, nex=None):
        self.key = key
        self.prev = prev
        self.next = nex
    
class DoublyLinkedLiset(object):
    def __init__(self):
        self.nil = Node(None)
        self.nil.next = self.nil
        self.nil.prev = self.nil
    
    def insert(self, x):
        X = Node(x)
        X.next = self.nil.next
        self.nil.next.prev = X
        self.nil.next = X
        X.prev = self.nil

    def listSearch(self, x):
        cur = self.nil.next
        while (cur != self.nil and cur.key != key):
            cur = cur.next
        
        return cur

    def deleteNode(self, X):
        if X == self.nil:
            return
        X.prev.next = X.next
        X.next.prev = X.prev
        #del X

    def deleteFirst(self):
        self.deleteNode(self.nil.next)

    def deleteLast(self):
        self.deleteNode(self.nil.prev)

    def deleteKey(self, x):
        self.deleteNode(self.listSearch(x))

    def printList(self):
        cur = self.nil.next
        ret = []
        
        while cur.key is not None:
            ret.append(cur.key)
            cur = cur.next
  
        print(' '.join(ret))

if __name__ == '__main__':

    n = int(input())
    dll = DoublyLinkedLiset()

    for i in range(n):
        command = input().split(" ")
        if command[0] == "insert":
            dll.insert(command[1])
        elif command[0] == "delete":
            dll.deleteKey(command[1])
        elif command[0] == "deleteFirst":
            dll.deleteFirst()
        elif command[0] == "deleteLast":
            dll.deleteLast()

    dll.printList()
    



### FIXED CODE ###

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

from collections import deque

if __name__ == '__main__':
    n = int(input())
    L = deque()

    for _ in range(n):
        command = input().split(" ")
        if command[0] == "insert":
            L.appendleft(command[1])
        elif command[0] == "delete":
            try:
                L.remove(command[1])
            except:
                pass
        elif command[0] == "deleteFirst":
            L.popleft()
        elif command[0] == "deleteLast":
            L.pop()

    print(" ".join(L))
n=int(input())
a=list(map(int,input().split()))
if len(set(a))==1:
    if n>=2*a[0] or n-1==a[0]:print("Yes")
    else:print("No")
elif len(set(a))==3:print("No")
else:
    s,S=sorted(list(set(a)))
    if n+a.count(s)>=2*S:print("Yes")
    else:print("No")

### FIXED CODE ###

n=int(input())

a=list(map(int,input().split()))
if len(set(a))==1:
    if n>=2*a[0] or n-1==a[0]:print("Yes")
    else:print("No")
elif len(set(a))>=3:print("No")
else:
    s,S=sorted(list(set(a)))
    k=a.count(s)
    if S==s+1 and 2*S-n<=k and S>k:print("Yes")
    else:print("No")
N, M = map(int, input().split())
MOD = 10**9+7
a = set()
for i in range(M):
    a.add(int(input()))

memo = [-1]*(N+1)
memo[0] = 1

def dodp(x):
    if memo[x] != -1:
        pass
    elif x in a:
        memo[x] = 0
    elif x == 1:
        memo[x] = dodp(x-1)
    else:
        memo[x] = dodp(x-1)+dodp(x-2)
    memo[x] %= MOD
    return memo[x]
    
dodp(N)
print(memo[N])


### FIXED CODE ###

N, M = map(int, input().split())
MOD = 10**9+7
a = set()
for i in range(M):
    a.add(int(input()))
step = [0]*(N+1)
step[0] = 1
for i in range(N+1):
    if i == 0:
        pass
    elif i in a:
        step[i] = 0
    elif i == 1:
        step[i] = step[0]
    else:
        step[i] = step[i-1]+step[i-2]
    step[i] %= MOD
print(step[N])
H,W = map(int,input().split())
S = [list(input()) for i in range(H)]

Rmin = 0
Rmax = 0
Cmin = 0
Cmax = 0

#行方向への探索
for r in range(H):
    #列方向への検索
    for c in range(W):
        #爆弾の場合、周りを加算
        if S[r][c] == ".":
            S[r][c] = 0
        elif S[r][c] == "#":
            if r == 0 :
                Rmin = r
                Rmax = r+2
            elif r == H-1:
                Rmin = r-1
                Rmax = r+1
            else:
                Rmin = r-1
                Rmax = r+2

            if c == 0:
                Cmin = c
                Cmax = c+2
            elif c == W-1:
                Cmin = c-1
                Cmax = c+1
            else:
                Cmin = c-1
                Cmax = c+2
            for i in range(Rmin,Rmax):
                for t in range(Cmin,Cmax):
                    if S[i][t] == "." or S[i][t] == 0:
                        S[i][t] = 1
                    elif not S[i][t] == "#":
                        S[i][t] += 1

for i in range(H):
    a = map(str,S[i])
    print(''.join(a))


### FIXED CODE ###

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

Rmin = 0
Rmax = 0
Cmin = 0
Cmax = 0

#行方向への探索
for r in range(H):
    #列方向への検索
    for c in range(W):
        #爆弾の場合、周りを加算
        if S[r][c] == ".":
            S[r][c] = 0
        elif S[r][c] == "#":
            if r == 0 and H == 1:
                Rmin = r
                Rmax = 1
            elif r == 0:    
                Rmin = r
                Rmax = r+2
            elif r == H-1:
                Rmin = r-1
                Rmax = r+1
            else:
                Rmin = r-1
                Rmax = r+2

            if c == 0 and W ==1 :
                Cmin = c
                Cmax = 1
            elif c == 0:
                Cmin = c
                Cmax = c+2
            elif c == W-1:
                Cmin = c-1
                Cmax = c+1
            else:
                Cmin = c-1
                Cmax = c+2
            for i in range(Rmin,Rmax):
                for t in range(Cmin,Cmax):
                    if S[i][t] == "." or S[i][t] == 0:
                        S[i][t] = 1
                    elif not S[i][t] == "#":
                        S[i][t] += 1

for i in range(H):
    a = map(str,S[i])
    print(''.join(a))
import sys
sys.setrecursionlimit(100000)

N = int(input())
ABC = [list(map(int, input().split())) for i in range(N-1)]
Q, K = map(int, input().split())
D = [0] * (N+1)
L = [[] for i in range(N+1)]
for a, b, c in ABC:
    L[a].append([b, c])
    L[b].append([a, c])


def dfs(n, np):
    for nc in L[n]:
        if nc[0] == np:
            continue
        else:
            D[nc[0]] = D[n] + nc[1]
            dfs(nc[0], n)


dfs(K, 0)
for i in range(Q):
    x, y = map(int, input().split())
    print(D[x] + D[y])


### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)

N = int(input())
ABC = [list(map(int, input().split())) for i in range(N-1)]
Q, K = map(int, input().split())
D = [0] * (N+1)
L = [[] for i in range(N+1)]
for a, b, c in ABC:
    L[a].append([b, c])
    L[b].append([a, c])


def dfs(n, np):
    for nc in L[n]:
        if nc[0] == np:
            continue
        else:
            D[nc[0]] = D[n] + nc[1]
            dfs(nc[0], n)


dfs(K, 0)
for i in range(Q):
    x, y = map(int, input().split())
    print(D[x] + D[y])
import sys
import math
from collections import defaultdict
input = sys.stdin.readline
N, H = [int(x) for x in input().strip().split()]
A = [0] * N
B = [0] * N
a_max = 0

for n in range(N):
    a, b = [int(x) for x in input().strip().split()]
    a_max = max(a_max, a)
    A[n] = a
    B[n] = b

if sum(B) >= H:
    ans = 0
    damage = 0
    while damage < H:
        ans += 1
        damage += B[ans-1]
    print(ans)
else:
    B = [b for b in B if b >= a_max]
    ans = len(B)
    ans += math.ceil((H - sum(B)) / a_max)
    print(ans)
import sys
import math
from collections import defaultdict
input = sys.stdin.readline
N, H = [int(x) for x in input().strip().split()]
A = [0] * N
B = [0] * N
a_max = 0

for n in range(N):
    a, b = [int(x) for x in input().strip().split()]
    a_max = max(a_max, a)
    A[n] = a
    B[n] = b

B = [b for b in B if b >= a_max]
ans = 0
damage = 0
if sum(B) >= H:
    while damage < H:
        ans += 1
        damage += B[ans-1]
    print(ans)
else:
    ans = len(B)
    damage = sum(B)
    ans += math.ceil((H - damage) / a_max)
    print(ans)


### FIXED CODE ###

import sys
import math
from collections import defaultdict
input = sys.stdin.readline
N, H = [int(x) for x in input().strip().split()]
A = [0] * N
B = [0] * N
a_max = 0

for n in range(N):
    a, b = [int(x) for x in input().strip().split()]
    a_max = max(a_max, a)
    A[n] = a
    B[n] = b

B = sorted([b for b in B if b >= a_max], reverse=True)
ans = 0
damage = 0
if sum(B) >= H:
    while damage < H:
        ans += 1
        damage += B[ans-1]
    print(ans)
else:
    ans = len(B)
    damage = sum(B)
    ans += math.ceil((H - damage) / a_max)
    print(ans)
N = int(input())
ld = [0] * N
for i in range(N):
    d = int(input())
    ld[i] = d

bucket = [0] * N
for j in range(N):
    bucket[ld[j] - 1] += 1

tower = 0

for k in range(N):
    if bucket[k] > 0:
        tower += 1

print(tower)

### FIXED CODE ###

N = int(input())
ld = [0] * N
for i in range(N):
    d = int(input())
    ld[i] = d

t = set(ld)

print(len(t))
def resolve():
    n,m= map(int,input().split())
    a = [int(input()) for _ in range(m)]
    d = [0]*(n+1)
    if not 1 in a : d[1] = 1
    if not 2 in a : d[2] = d[1] + 1
    for i in range(3,n+1):
        if not i in a :
            d[i] += d[i-1] + d[i-2]
    print(d[i]%1000000007)

resolve()


### FIXED CODE ###

# DP
mod = 1000000007
 
n, m = map(int, input().split())
b_list = [True] * (n+1)
dp = [0 for _ in range(n+1)]
for i in range(m):
    b_list[int(input())] = False
 
dp[0] = 1
for i in range(n):
    for j in range(i+1, min(n, i+2)+1):
        if b_list[j] == True:
            dp[j] += dp[i]
            dp[j] %= mod
# print(b_list)
# print(dp)
print(dp[n])
def main():
    n=int(input())
    a=[int(input()) for _ in [0]*(n-1)]
    a=[[i+2,a[i]] for i in range(n-1)]
    l=[[] for _ in [0]*n]
    for i,j in a:
        l[j-1].append(i-1)
    def dps(i):
        if l[i]==[]:
            return 1
        _max=0
        _min=10**6
        for j in l[i]:
            temp=dps(j)
            _max=max(temp,_max)
            _min=min(temp,_min)
        return max(_max,_min+1)
    print(dps(0))
main()

### FIXED CODE ###

def main():
    import sys
    sys.setrecursionlimit(100000)
    n=int(input())
    a=[int(input()) for _ in [0]*(n-1)]
    a=[[i+2,a[i]] for i in range(n-1)]
    l=[[] for _ in [0]*n]
    for i,j in a:
        l[j-1].append(i-1)
    def dps(i):
        if l[i]==[]:
            return 0
        temp=[]
        for j in l[i]:
            temp.append(dps(j))
        temp.sort(reverse=True)
        temp=[temp[i]+i+1 for i in range(len(temp))]
        return max(temp)
    print(dps(0))
main()
n,c=map(int,input().split())
d=[[] for i in range(c)]
w=[0]*100001
for i in range(n):
    s,t,c=map(int,input().split())
    d[c-1].append((s,t))
for i in range(c):
    d[i].sort()
    e=d[i][0][1]
    for j in range(len(d[i])):
        if len(d[i])==1:
            w[d[i][0][0]]+=1
            w[d[i][0][1]+1]-=1
        elif j==0:
            w[d[i][0][0]]+=1
            e=d[i][0][1]
        elif j+1==len(d[i]):
            if e==d[i][j][0]:
                w[d[i][j][1]+1]-=1
            else:
                w[e+1]-=1
                w[d[i][j][0]]+=1
                w[d[i][j][1]+1]-=1
        else:
            if e==d[i][j][0]:
                e=d[[i][j][1]]
            else:
                w[e+1]-=1
                w[d[i][j][0]]+=1
                e=d[i][j][1]
ans=chk=0
for i in w:
    chk+=i
    ans=max(ans,chk)
print(ans)


### FIXED CODE ###

n,c=map(int,input().split())
d=[[] for i in range(c)]
w=[0]*100002
for i in range(n):
    s,t,x=map(int,input().split())
    d[x-1].append((s,t))
for i in range(c):
    d[i].sort()
    e=0
    for j in range(len(d[i])):
        if len(d[i])==1:
            w[d[i][0][0]]+=1
            w[d[i][0][1]+1]-=1
        elif j==0:
            w[d[i][0][0]]+=1
            e=d[i][0][1]
        elif j+1==len(d[i]):
            if e!=d[i][j][0]:
                w[e+1]-=1
                w[d[i][j][0]]+=1
            w[d[i][j][1]+1]-=1
        else:
            if e!=d[i][j][0]:
                w[e+1]-=1
                w[d[i][j][0]]+=1
            e=d[i][j][1]
ans=chk=0
for i in w:
    chk+=i
    ans=max(ans,chk)
print(ans)
sam = input()
ans = input()
for i in range(1,len(ans)) :
    if (ans[:i] in sam) == False : break
if ((ans[i - 1 :]) in sam) == True : print('Yes')
else                             : print('No')

### FIXED CODE ###

s = input() * 2
p = input()
 
if p in (s):
    print("Yes")
else:
    print("No")
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

Q = sum(B)
for i in range(N-1):
    if A[i+1] == A[i]+1:
        Q += C[A[i]]
        
print(Q)
        


### FIXED CODE ###

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

Q = sum(B)
for i in range(N-1):
    if A[i+1] == A[i]+1:
        Q += C[A[i]-1]
        
print(Q)
n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    a = [list(map(int, input().split()))]
    a[i] += [sum(a[i])]
for i in range(m):
    b += [a[:][i]]
    a += [b]
for i in range(n):
    print(*a[i])


### FIXED CODE ###

n, m = map(int, input().split())
a = []
b = []
for i in range(n):
    a += [list(map(int, input().split()))]
    a[i] += [sum(a[i])]
for i in range(m+1):
    b += [sum(x[i] for x in a)]
a += [b]
for i in range(n+1):
    print(*a[i])
s = raw_input()
N = int(raw_input())
dis = [ord('z')-ord(c) for c in s]
for idx, d in enumerate(dis[:-1]):
    if d <= N:
        s[idx] = 'a'
        N -= d
if N > 0:
    N %= 27
    t = (dis[-1]-N) % 27
    s[-1] = chr(ord('z') - t)
print s

### FIXED CODE ###

s = bytearray(raw_input())
N = int(raw_input())
dis = [ord('z')-c for c in s]

for idx, d in enumerate(dis[:-1]):
    if d!=25 and d+1 <= N:
        s[idx] = 'a'
        N -= (d+1)

if N > 0:
    N %= 26
    t = (dis[-1]-N) % 26
    s[-1] = chr(ord('z') - t)
print s
import math
N = int(input())
current_lcm = None
for _ in range(N):
    t = int(input())
    if current_lcm is None:
        current_lcm = t
        continue
    current_lcm = current_lcm * t // math.gcd(current_lcm, t)
print(current_lcm)

### FIXED CODE ###

def gcd(a, b):
    a, b = max([a, b]), min([a, b])
    if b == 0:
        return a
    return gcd(b, a % b)
N = int(input())
current_lcm = None
for _ in range(N):
    t = int(input())
    if current_lcm is None:
        current_lcm = t
        continue
    current_lcm = current_lcm * t // gcd(current_lcm, t)
print(current_lcm)
n = input()
s = sum(map(int,n))
if int(n)% s == 0:
    print("Yes")
else:
    print("No

### FIXED CODE ###

n = input()
s = sum(map(int,n))
if int(n) % s == 0:
    print("Yes")
else:
    print("No")
N = int(input())
S = int(input())

def f(b,n):
    if n//b==0:
        return n
    else:
        return n%b + f(b,n//b)

ans = -1
if S==N:
    ans = N+1
else:
    for b in range(2,int(N**.5)+1):
        if f(b,N)==S:
            ans = b
            break

if ans == -1:
    for i in range(int(N**.5)+1,0,-1):
        b = (N-S)//i + 1
        if b>0:
            if f(b,N)==S:
                ans = b
                break

print(ans)

### FIXED CODE ###

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

def f(b,n):
    if n//b==0:
        return n
    else:
        return n%b + f(b,n//b)

ans = -1
if S==N:
    ans = N+1
else:
    for b in range(2,int(N**.5)+1):
        if f(b,N)==S:
            ans = b
            break

if ans == -1:
    for i in range(int(N**.5)+1,0,-1):
        b = (N-S)//i + 1
        if b>1:
            if f(b,N)==S:
                ans = b
                break

print(ans)
H,W,M = map(int,input().split())
HW = []
for i in range(M):
	HW.append(list(map(int,input().split())))

#H方向の走査
Hmax = 0
Hmax_temp = 0
y_max = []
for y in range(1,H+1):
	for j in HW:
		if y == j[0]:
			Hmax_temp += 1
	if Hmax_temp >= Hmax:
		Hmax = Hmax_temp
		y_max.append(y)
	Hmax_temp = 0

#W方向の走査
Wmax = 0
Wmax_temp = 0
x_max = []
for x in range(1,W+1):
	for j in HW:
		if x == j[1]:
			Wmax_temp += 1
	if Wmax_temp >= Wmax:
		Wmax = Wmax_temp
		x_max.append(x)
	Wmax_temp = 0

#爆弾設置位置に対象が存在するか？
flag = False
for i in y_max:
	for  j in x_max:
		if [i,j] not in HW:
			flag = True
			break
	if flag:
		break

#答えのセット
if flag:
	ans = Wmax + Hmax
elif :
	ans = Wmax + Hmax - 1
print(ans)

### FIXED CODE ###



H,W,M = map(int,input().split())

Hmax_temp = [0]*(H+1)
Wmax_temp = [0]*(W+1)
Hmax = 0
Wmax = 0
Bomb = dict()
for i in range(M):
	H_M,W_M = map(int,input().split())
	Hmax_temp[H_M] += 1
	Wmax_temp[W_M] += 1
	Bomb[(H_M,W_M)] = 1

Hmax = max(Hmax_temp)
Wmax = max(Wmax_temp)

#H方向の走査
y_max = []
for i in range(H+1):
	if Hmax == Hmax_temp[i]:
		y_max.append(i)
		
#W方向の走査
x_max = []
for j in range(W+1):
	if Wmax == Wmax_temp[j]:
		x_max.append(j)

#爆弾設置位置に対象が存在するか？
flag = False
for i in y_max:
	for  j in x_max:
		if (i,j) not in Bomb:
			flag = True
			break
	if flag:
		break

#答えのセット
if flag:
	ans = Wmax + Hmax
else:
	ans = Wmax + Hmax - 1
print(ans)
s = list(input())
key = ['A','T','G','C']

count = 0
ans = 0
for i in range(n):
  if s[i] in key: count += 1
  else: count = 0
  ans = max(ans,count)
print(ans)


### FIXED CODE ###

s = list(input())
key = ['A','T','G','C']
count = 0
flag = False
ans = 0
for i in range(len(s)):
  if s[i] in key:
    count += 1
    flag = True
  if flag==True and (s[i] not in key):
    ans = max(ans,count)
    count = 0
    flag = False
ans = max(ans,count)
print(ans)
import sys

cin = sys.stdin
cin = open("in.txt", "r")

x = int(cin.readline())
c = x//11
cnt = c*2
r = x%11
# print(r)
if r>0:
    cnt +=1
    if r>6:
        cnt +=1

print(cnt)


### FIXED CODE ###

import sys

cin = sys.stdin

x = int(cin.readline())
c = x//11
cnt = c*2
r = x%11
# print(r)
if r>0:
    cnt +=1
    if r>6:
        cnt +=1

print(cnt)
import math

r = int(input())

print('%f %f' %(r ** 2 * math.pi, r * 2 * math.pi))

### FIXED CODE ###

import math

r = float(input())

print('%f %f' %(r ** 2 * math.pi, r * 2 * math.pi))
s = list(map(int, input().split(' ')))
k = s[0]
x = s[1]

min = −1000000
max =  1000000


if x-k+1 > min:
  min = x-k+1

if x+k-1 < max:
  max = x+k-1

for i in range(min,max)
	print(i,end=' ')
print()
 

### FIXED CODE ###

s = list(map(int, input().split(' ')))
k = s[0]
x = s[1]

min = 1000000*-1
max =  1000000


if x-k+1 > min:
  min = x-k+1

if x+k < max:
  max = x+k

for i in range(min,max):
	print(i,end=' ')
print()