Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

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

B=[0]*p

INV=[None]*p# 1/aのリストを予め作っておく.
for i in range(1,p):
    INV[i]=pow(i,p-2,p)

Combi=[None]*p# Combi[i]=nCi を表す
Combi[0]=1
for i in range(1,p):
    Combi[i]=Combi[i-1]*(p-i)*INV[i] %p


for i in range(p):
    if A[i]==0:
        continue

    B[0]+=1
    for j in range(p):
        B[j]=(B[j]-Combi[j]*pow(-i,p-1-j,p))%p

print(*[b%p for b in B])

### FIXED CODE ###

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

B=[0]*p

INV=[None]*p# 1/aのリストを予め作っておく.
for i in range(1,p):
    INV[i]=pow(i,p-2,p)

Combi=[None]*p# Combi[i]=nCi を表す
Combi[0]=1
for i in range(1,p):
    Combi[i]=Combi[i-1]*(p-i)*INV[i] %p


for i in range(p):
    if A[i]==0:
        continue

    B[0]+=1
    POW=1
    for j in range(p):
        B[p-1-j]=(B[p-1-j]-Combi[j]*POW)%p
        POW=POW*(-i)%p

print(*[b%p for b in B])
### BUGGY CODE ###

import sys
from itertools import combinations
from collections import Counter
ct = Counter()
Ass = []
N, M, X = map(int, input().split())
for i in range(N):
	As = list(map(int, input().split()))
	ct[i] = As[0]
	Ass.append(As[1:])

C = []
for z in range(M):	
	B = []
	for i in range(N):
		B.append(Ass[i][z])
	D = []
	for i in range(1, N+1):
		l = list(combinations(range(N), i))
		
		for j in l:
			s = 0
			for jj in j:
				s += B[jj]
			if s >= X:
				D.append(j)
	C.append(D)

cand = []
for i in C[0]:
	flag=True
	for j in C[1:]:
		if i not in j:
			flag=False
			break
	if flag:
		cand.append(i)
ans = 10**9


for i in cand:
	s = 0
	for j in i:
		s+= ct[j]
	if s < ans:
		ans = s

if ans == 10**9:
	print('-1')
else:
	print(ans)

### FIXED CODE ###

import sys
from itertools import combinations
from collections import Counter
ct = Counter()
Ass = []
ans = []
N, M, X = map(int, input().split())
for i in range(N):
	Ass.append(list(map(int, input().split())))

for z in range(M):	
	B = []
	for i in range(N):
		B.append(Ass[i][z])
	D = []
	for i in range(1, N+1):
		for j in combinations(Ass, i):
			flag = True
			d = [0]*(M+1)
			for k in j:  # (2, 7, 3)
				for l in range(M+1):
					d[l] += k[l]
			for x in range(1, M+1):
				if d[x] >= X:
					pass
				else:
					flag=False
					break
			if flag:
				ans.append(d[0])


if len(ans) > 0:
	print(min(ans))
else:
	print('-1')
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int):
    for i in range(1, 3501):
        for j in range(i, 3501):
            if (4*i*j - N*j - N*i) == 0:
                continue
            h, r = divmod((N*i*j), 4*i*j - N*j - N*i)
            if r == 0 and 0 <= h:
                print(h, i, j)
                exit()
            

    return

N = int(input())
solve(N)

# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
# def main():
#     def iterate_tokens():
#         for line in sys.stdin:
#             for word in line.split():
#                 yield word
#     tokens = iterate_tokens()
#     N = int(next(tokens))  # type: int
#     solve(N)

# if __name__ == '__main__':
#     main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(N: int):
    for i in range(1, 3501):
        for j in range(i, 3501):
            z = 4*i*j - N*(j+i)
            if z > 0:
                h, r = divmod((N*i*j), z)
                if r == 0:
                    print(h, i, j)
                    exit()
            

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    solve(N)

if __name__ == '__main__':
    main()


# #!/usr/bin/env python3
# n = int(input())
# for i in range(1, 3501):
#   for j in range(1, 3501):
#     seed = 4 * i * j - n * (i + j) 
#     if seed > 0:
#       k, mod = divmod(n * i * j, seed) 
#       if mod == 0:
#         print(i, j, k)
#         exit()
### BUGGY CODE ###

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

d = [0]*(max(a)+3)
s = set(a)
for i in s:
    c = a.count(i)
    d[i+1] += c
    d[i] += c
    d[i+2] += c

print(max(d))

### FIXED CODE ###

cnt=[0]*100002
input()
for x in map(int,input().split()):
    cnt[x]+=1
    cnt[x+1]+=1
    cnt[x+2]+=1
print(max(cnt))
### BUGGY CODE ###

def calc_prime(n):
    primes = set([2, 3, 5])
    for x in range(7, n + 1, 2):
        is_p = True
        for p in primes:
            if x % p == 0:
                #print(x, p)
                is_p = False
                break

        if is_p:
            primes.add(x)

    return primes
    

def main():
    q = int(input())
    range_set = []
    mx = 0
    for _ in range(q):
        l, r = [int(x) for x in input().split()]
        mx = max(mx, r)
        range_set.append((l, r))

    primes = calc_prime(mx)
    #print(primes)
    for l, r in range_set:
        #print(l, r)
        c = 0
        for x in range(l, r + 1, 2):
            if x in primes and (x + 1) / 2 in primes:
                c += 1

        print(c)


main()


### FIXED CODE ###

def calc_prime(n):
    primes = set(list(range(3, n, 2)))
    primes.add(2)
    for a in range(3, n, 2):
        for i in range(a, n):
            x = a * i
            if x >= n:
                break
            if x in primes:
                primes.remove(x)

    return primes


def collect_likes(ps):
    likes = set([p for p in ps if (p + 1) / 2 in ps])
    return likes


def line(xs, n):
    ps = list(xs)
    ps.sort()
    cs = [0] * n
    s = 0
    for i in range(n):
        if i in xs:
            cs[i] = s
            s += 1
        else:
            cs[i] = s

    return cs


def main():
    n = 10 ** 5 + 9
    primes = calc_prime(n)
    likes = collect_likes(primes)
    cums = line(likes, n)
    #print(sorted(list(primes))[:100])
    #print(sorted(list(likes))[:100])
    #print(cums[:10])

    q = int(input())
    for _ in range(q):
        l, r = [int(x) for x in input().split()]
        ans = cums[r + 1] - cums[l]
        print(ans)


main()
### BUGGY CODE ###

N=int(input())
dict=[]
for i in range(N):
    a=input().split()
    if a[0]=="insert":
        dict.append(a[1])
    elif a[0]=="find":
        if a[1] in dict:
            print("yes")
        else:
            print("no")

### FIXED CODE ###

# coding: utf-8
# Here your code !
N=int(input())
dict={}
for i in range(N):
    a,b=input().split()
    if a=="insert":
        dict[b]=i
    else:
        if b in dict:
            print("yes")
        else:
            print("no")
### BUGGY CODE ###

import fractions
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
cnt = 0
lcm = 1
for i in range(n):
    a[i]//=2
    lcm = lcm*a[i]//fractions.gcd(lcm,a[i])
c = [0]*n
flag = False
for i in range(n):
    while a[i]%2==0:
        a[i]//=2
        c[i]+=1
    for j in range(i):
        if c[i]!=c[j]:
            flag = True
            break
if flag:
    print(0)
else:
    tmp = m//lcm
    print((tmp+1)//2)

### FIXED CODE ###

import fractions #math.gcdは非対応なので解答にはfractions.gcdを使う
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
lcm = 1
for i in range(n):
    a[i]//=2
    lcm = lcm*a[i]//fractions.gcd(lcm,a[i])
flag = False
loopf = True
while loopf:
    tmp = a[0]%2
    for i in range(1,n):
        if a[i]%2!=tmp:
            flag = True
            loopf = False
            break
    if tmp==1 and loopf:
        loopf = False
    if tmp==0:
        for i in range(n):
            a[i]//=2
        
if flag:
    print(0)
else:
    tmp = m//lcm
    print((tmp+1)//2)
### BUGGY CODE ###

S=list(map(str,input()))
ZERO=[]
T=[]
U=[]
CK=[]
odd=0
for i in range(len(S)):
  T.append(1)
for i in range(1,len(S)):
  if S[i-1]=="R" and S[i]=="R":
    ZERO.append(i-1)
  if S[i]=="L" and S[i-1]=="L":
    ZERO.append(i)
for i in range(len(ZERO)):
  CK.append(T[ZERO[i]])
U=T[:]
while sum(CK)!=0:
  for i in range(1,len(S)):
    if T[i-1]>0 and S[i-1]=="R":
      U[i]=U[i]+T[i-1]
      U[i-1]=U[i-1]-T[i-1]
    if T[i]>0 and S[i]=="L":
      U[i-1]=U[i-1]+T[i]
      U[i]=U[i]-T[i]
  odd=odd+1
  for i in range(len(ZERO)):
    CK[i]=U[ZERO[i]]
  T=U[:]
if odd%2==0:
  print(" ".join(map(str,T)))
else:
  for i in range(1,len(S)):
    if T[i-1]>0 and S[i-1]=="R":
      U[i]=U[i]+T[i-1]
      U[i-1]=U[i-1]-T[i-1]
    if T[i]>0 and S[i]=="L":
      U[i-1]=U[i-1]+T[i]
      U[i]=U[i]-T[i]
  print(" ".join(map(str,U)))

### FIXED CODE ###

S=list(map(str,input()))
N=len(S)
Q=[0]*N
R=[]
R1=[0]*N
L1=[0]*N
L=[]
V=[0]*N
for i in range(0,N):
  if S[i]=="R" and S[i+1]=="L":
    R.append(i)
  elif S[i]=="L" and S[i-1]=="R":
    L.append(i)
  else: V[i]=1

for i in R+L:
  Q[i]=1

x=0
for r in R:
  while x!=r:
    R1[x]=r
    x=x+1
x=N-1
for l in reversed(L):
  while x!=l:
    L1[x]=l
    x=x-1

for i in range(N):
  if V[i]==1:
    if S[i]=="R":
      if (R1[i]-i)%2==0:
        Q[R1[i]]=Q[R1[i]]+1
      else:
        Q[R1[i]+1]=Q[R1[i]+1]+1
    else:
      if (i-L1[i])%2==0:
        Q[L1[i]]=Q[L1[i]]+1
      else:
        Q[L1[i]-1]=Q[L1[i]-1]+1

print(*Q)
### BUGGY CODE ###

import copy
s=input().split()
num=[int(i) for i in s[:3]]
K=int(s[3])
num_=[0,0,0]
for i in range(K):
  for j in range(3):
    num_[j]=num[(j+1)%3]+num[(j+2)%3]
  num=copy.deepcopy(num_)
if abs(num[0]-num[1])>10**18:
  print("Unfair")
else:
  print(num[0]-num[1])

### FIXED CODE ###

s=input().split()
ans=int(s[0])-int(s[1])
if abs(ans)>10**18:
  print("Unfair")
elif int(s[3])%2==0:
  print(int(s[0])-int(s[1]))
else:
  print(-1*(int(s[0])-int(s[1])))
### BUGGY CODE ###

a =list()
n = int(input())
for _ in range(n):
    tmp = int(input()) 
    if tmp in a:
        a.remove(tmp)
    else:
        a.append(tmp)
print(len(a))

### FIXED CODE ###

from collections import Counter
a =[]
n = int(input())
for _ in range(n):
    a.append(int(input()))
b = Counter(a).values()
print(sum([i % 2 for i in b]))
### BUGGY CODE ###

n=int(input())
lis=[]
ans=[]
for i in range(n):
    lis.append(input())
    ans.append([0,0,0,0,0,0,0,0,0,0])
    for j in range(10):
        ans[i][j]=lis[i][j]
    ans[i].sort()

ans.sort()
a=0
for i in range(n-1):
    for j in range(n-1-i):
        if ans[i]==ans[i+j+1]:
            a+=1
        else:
            break

print(int(a))


### FIXED CODE ###

n=int(input())
ans=[]
for i in range(n):
    qw=input()
    ans.append([0,0,0,0,0,0,0,0,0,0])
    for j in range(10):
        ans[i][j]=qw[j]
    ans[i].sort()

lis=[]
for i in range(n):
    lis.append(ans[i][0])
    for j in range(9):
        lis[i]+=ans[i][j+1]

a=0
#print(lis)

dic={lis[0]:1}
for i in range(n-1):
    if lis[i+1] in dic.keys():
        a+=dic[lis[i+1]]
        dic[lis[i+1]]+=1
    else:
        dic[lis[i+1]]=1

print(int(a))
### BUGGY CODE ###

#EDPC L
import sys
sys.setrecursionlimit(10**5)

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

#dp[l][r]:=区間[l,r]が残っている時の(直後の人の最終的な得点-そうじゃない方の最終的な得点）

dp=[[-1]*N for _ in range(N)]

def rec(l,r):
    if dp[l][r]!=-1:
        return dp[l][r]
    
    if l==r:
        dp[l][r]=a[l]
        return dp[l][r]
    
    dp[l][r]=max(a[l]-rec(l+1,r),a[r]-rec(l,r-1))

    return dp[l][r]


print(rec(0,N-1))


### FIXED CODE ###

#EDPC L メモ化再帰じゃTLEで通らないのでやり直し

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

#dp[l][r]:=区間[l,r]が残っている時の(直後の人の最終的な得点-そうじゃない方の最終的な得点）

dp=[[-1]*N for _ in range(N)]

for k in range(N):
    dp[k][k]=a[k]

for r in range(1,N):
    for l in reversed(range(r)):
        dp[l][r]=max(a[l]-dp[l+1][r],a[r]-dp[l][r-1])

print(dp[0][N-1])
### BUGGY CODE ###

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

ret = W - 1 + H - 1

for i in range(1 << (H - 1)):
    sep = bin(i)[2:].rjust(H - 1, '0')[::-1]

    tile_idx = [0] * H
    cut = 0

    for j in range(H):
        tile_idx[j] = cut

        if j == H - 1:
            break

        if sep[j] == '1':
            cut += 1

    cnt_lst = [0] * (cut + 1)

    num_cnt = 0

    for w in range(W):
        col_new = [0] * (cut + 1)

        flag = False
        for h in range(H):
            if S[h][w] == 1:
                idx = tile_idx[h]
                col_new[idx] += 1

        for a in col_new:
            if a > K:
                flag = True
                break

        for k in range(cut + 1):
            if cnt_lst[k] + col_new[k] > K:
                num_cnt += 1
                cnt_lst = col_new.copy()
                flag = True
                break

        if not flag:
            for k in range(cut + 1):
                cnt_lst[k] += col_new[k]

    ret = min(ret, num_cnt + cut)


print(ret)


### FIXED CODE ###

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

ret = W - 1 + H - 1

for i in range(1 << (H - 1)):
    sep = bin(i)[2:].rjust(H - 1, '0')[::-1]

    tile_idx = [0] * H
    cut = 0

    for j in range(H):
        tile_idx[j] = cut

        if j == H - 1:
            break

        if sep[j] == '1':
            cut += 1

    cnt_lst = [0] * (cut + 1)
    num_cnt = 0

    for w in range(W):
        col_new = [0] * (cut + 1)

        flag = False
        flag1 = False
        for h in range(H):
            if S[h][w] == 1:
                idx = tile_idx[h]
                col_new[idx] += 1

        for a in col_new:
            if a > K:
                flag1 = True
                break

        if flag1:
            break

        for k in range(cut + 1):
            if cnt_lst[k] + col_new[k] > K:
                num_cnt += 1
                for l in range(cut + 1):
                    cnt_lst[l] = col_new[l]

                flag = True
                break

        if not flag:
            for k in range(cut + 1):
                cnt_lst[k] += col_new[k]

    if not flag1:
        ret = min(ret, num_cnt + cut)


print(ret)
### BUGGY CODE ###

n = int(input())
s = input()
cnt_l = []
for i in range(n):
  cnt = 0
  cnt += s[:i].count("W")
  cnt += s[i+1:].count("E")
  cnt_l.append(cnt) 
print(min(cnt_l))

### FIXED CODE ###

import numpy
n = int(input())
s = input()
Ws = [0] + [1 if i == "W" else 0 for i in s]
Ws_sum = list(numpy.cumsum(Ws))
cnt_l = []
for i in range(n):
    cnt_l.append(Ws_sum[i]+n-i-1-Ws_sum[-1]+Ws_sum[i+1])
print(min(cnt_l))
### BUGGY CODE ###

h,w=map(int,input().split())
h+=2
w+=2
s=[]
l=[[0 for i in range(w)]for j in range(h)]
s.append(["#"]*w)
for i in range(h-2):
    a=input()
    s.append("#"+a+"#")
s.append(["#"]*w)

yl=[[]for j in range(h)]
tl=[[]for j in range(w)]
for i in range(h):
    for j in range(w):
        if s[i][j]=="#":
            yl[i].append(j)
            tl[j].append(i)
ans=0
import bisect
for i in range(1,h-1):
    for j in range(1,w-1):
        if s[i][j]!="#":
            n=bisect.bisect(yl[i],j)
            m=bisect.bisect(tl[j],i)
            p=0
            p+=yl[i][n]-yl[i][n-1]+tl[j][m]-tl[j][m-1]-3
            
            ans=max(ans,p)
                
        
print(ans)

### FIXED CODE ###

h,w=map(int,input().split())
s=[]
l=[[0 for i in range(w)]for j in range(h)]
 
for i in range(h):
    a=input()
    s.append(a)

yoko=[[0 for j in range(w)] for j in range(h)]
tate=[[0 for j in range(w)] for j in range(h)]

for i in range(h):
    p=0
    for j in range(w):
        if s[i][j]=="#" or j==w-1:
            if s[i][j]==".":
                for k in range(p):
                    yoko[i][j-k-1]+=p+1
                yoko[i][j]+=p+1
            else:
                for k in range(p):
                    yoko[i][j-k-1]+=p
            p=0
        elif s[i][j]==".":
            p+=1
for i in range(w):
    p=0
    for j in range(h):
        if s[j][i]=="#" or j==h-1:
            if s[j][i]==".":
                for k in range(p):
                    tate[j-k-1][i]+=p+1
                yoko[j][i]+=p+1
            else:
                for k in range(p):
                    tate[j-k-1][i]+=p
            p=0
        elif s[j][i]==".":
            p+=1
ans=0
for i in range(h):
    for j in range(w):
        ans=max(ans,yoko[i][j]+tate[i][j]-1)

print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
res = []
for i in range(1,n+1):
  res.append(a.index(i)+1)
print(*res)

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
res = [0] * n
for i,val in enumerate(a):
  res[val-1] = i+1
print(*res)
### BUGGY CODE ###

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

sum = 0
j = 0

for i in range(N):
  for j in range(i+1, N):
    a = s[i] * s[j]
    sum += a

sum  = sum % (10**9 + 7)    
print(sum)

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
mod = 10**9 + 7

sum = 0
f = 0

for i in range(n-1):
    f = f + a[i]
    sum += f * a[i+1]
 
print(sum % mod)
### BUGGY CODE ###

n = input()
lst = input().split()
isTrue = True

for i in lst:
  if lst.count(i) > 1:
    print('NO')
    isTrue = False
    break

if isTrue == True:
  print('YES')

### FIXED CODE ###

n = input()
lst = input().split()
sett = set(lst)

if len(lst) == len(sett):
  print('YES')
else:
  print('NO')
### BUGGY CODE ###

import sys

X = int(input())
A = []
for i in range(1, int(X**0.5)+1):
    if X%i == 0:
        A.append([i, X//i])

for i in A:
    for a in range(1, X+1):
        b = a - i[0]
        if a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4 == i[1]:
            print(a, b)
            sys.exit()

### FIXED CODE ###

import sys

X = int(input())
A = []
for i in range(1, int(X**0.5)+1):
    if X%i == 0:
        A.append([i, X//i])

for i in A:
    for a in range(1, int(X**0.5)+1):
        b = a - i[0]
        if a**4 + a**3*b + a**2*b**2 + a*b**3 + b**4 == i[1]:
            print(a, b)
            sys.exit()
### BUGGY CODE ###

import sys
input=sys.stdin.readline
n,s=int(input()),input()

cnt=0
flag1=[]
ans=[]
for i in range(n-2):
    flag2=[]
    if s[i] in flag1:continue
    flag1.append(s[i])
    for j in range(i+1,n-1):
        if s[i]!=s[j] and s[j] in flag2:continue
        flag2.append(s[j])
        for k in range(j+1,n):
            ans.append(s[i]+s[j]+s[k])
#print(ans,flag1,flag2)
print(len(set(ans)))

### FIXED CODE ###

n=int(input())
s=input()
#000~999からいくつ作れるか試す
num='0123456789'
ans=0
#候補の暗証番号を生成する
for first_num in num:
    for second_num in num:
        for third_num in num:
            temp_lock=first_num+second_num+third_num
            temp_cnt=0
            for i in s:
                if temp_cnt==0 and i==temp_lock[0]:
                    temp_cnt=1
                elif temp_cnt==1 and i==temp_lock[1]:
                    temp_cnt=2
                elif temp_cnt==2 and i==temp_lock[2]:
                    ans+=1
                    break
print(ans)
### BUGGY CODE ###

import sys
from heapq import heappop, heappush
from operator import itemgetter
from collections import deque, defaultdict, Counter
from bisect import bisect_left, bisect_right
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
MOD = 10**9 + 7
INF = float('inf')

def sol():
    N = int(input())
    S = input().rstrip()
    T = [-1] * N

    sToIndex = defaultdict(int)
    now = 1

    for i, s in enumerate(S):
        if not s in sToIndex:
            T[i] = now
            sToIndex[s] = now
            now += 1
        else:
            T[i] = sToIndex[s]

    cumT = [0] * (N + 1)
    for i in range(1, N + 1):
        cumT[i] = cumT[i - 1] + T[i - 1]

    cumTList = []
    for left in range(N):
        for right in range(left + 1, N + 1):
            cumTList.append((cumT[right] - cumT[left], left, right))

    matchList = defaultdict(list)
    for v, l, r in cumTList:
        matchList[v].append((l, r))

    ans = 0
    for v, match in matchList.items():
        for i in range(len(match)):
            for j in range(i + 1, len(match)):
                l1, r1 = match[i]
                l2, r2 = match[j]
                if l2 < r1:
                    continue
                if S[l1: r1] == S[l2: r2]:
                    ans = max(ans, r1 - l1)

    print(ans)

sol()

### FIXED CODE ###

from collections import deque

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

def isOk(leng):
    hashList = set()
    que = deque([])
    for left in range(N - leng + 1):
        hs = hash(S[left: left + leng])
        if hs in hashList:
            return True
        que.append(hs)
        if len(que) >= leng:
            hashList.add(que.popleft())
    return False

ok = 0
ng = N

while ng - ok > 1:
    mid = (ng + ok) // 2
    if isOk(mid):
        ok = mid
    else:
        ng = mid

print(ok)
### BUGGY CODE ###

#!/usr/bin/python3

import sys
from bisect import bisect_left
from collections import defaultdict

sys.setrecursionlimit(1000000)

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

nbs = defaultdict(list)

for i in range(n - 1):
    (u, v) = map(int, input().split())
    nbs[u - 1].append(v - 1)
    nbs[v - 1].append(u - 1)


mlen =  [ 0 ] * n
dp = [ float('inf') ] * n

def getmlen(cur, p, ctail):
    idx = bisect_left(dp, a[cur])
    ov = dp[idx]
    if ctail < idx:
        ctail = idx

    dp[idx] = a[cur]
    mlen[cur] = ctail + 1
    
    for ch in nbs[cur]:
        if ch == p:
            continue

        getmlen(ch, cur, ctail)
    dp[idx] = ov

getmlen(0, -1, 0)

for i in range(n):
    print(mlen[i])


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
from bisect import bisect_left
 
N = int(input())
a = [int(i) for i in input().split()]
vec = [[] for _ in range(N)]
for _ in range(N - 1) :
  u, v = map(int, input().split())
  vec[u - 1].append(v - 1)
  vec[v - 1].append(u - 1)
 
lis = [a[0]]
ret = [0] * N
def dfs(cur, pre) :
  for nex in vec[cur] :
    if nex == pre : continue
    if a[nex] > lis[-1] :
      lis.append(a[nex])
      ret[nex] = len(lis)
      dfs(nex, cur)
      lis.pop()
    else :
      pos = bisect_left(lis, a[nex])
      v = lis[pos]
      lis[pos] = a[nex]
      ret[nex] = len(lis)
      dfs(nex, cur)
      lis[pos] = v
 
dfs(0, -1)
 
ret[0] = 1
for i in range(N) :
  print(ret[i])
### BUGGY CODE ###

N,K,Q=map(int,input().split())
A = [K] * N
for i in range(Q):
    a=int(input())-1
    for j in range(N):
        if j!=a:
            A[j]=A[j]-1
for k in range(N):
    if A[k]>0:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

N,K,Q=map(int,input().split())
A = [0] * N
if K>Q:
    for i in range(N):
        print("Yes")
else:
    for i in range(Q):
        a=int(input())-1
        A[a]+=1
    for k in range(N):
        if K>Q-A[k]:
            print("Yes")
        else:
            print("No")
### BUGGY CODE ###

def main():
    h, w, m = map(int, input().split())
    height = [0 for _ in range(h)]
    width = [0 for _ in range(w)]
    target = set()
    for _ in range(m):
        x, y = map(lambda x: int(x) - 1, input().split())
        target.add((x, y))
        height[x] += 1
        width[y] += 1
    ans = 0
    for i in range(h):
        for j in range(w):
            now_ans = height[i] + width[j]
            if (i, j) in target:
               now_ans -= 1
            ans = max(ans, now_ans)
    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def max_bomb_set(l):
    l.sort(key=lambda x: x[0], reverse=True)
    res = []
    for cnt, tag in l:
        if cnt == l[0][0]:
            res.append(tag)
        else:
            break
    return res, l[0][0]


def main():
    h, w, m = map(int, input().split())
    height = [[0, i] for i in range(h)]
    width = [[0, i] for i in range(w)]
    target = set()
    for _ in range(m):
        x, y = map(lambda x: int(x) - 1, input().split())
        target.add((x, y))
        height[x][0] += 1
        width[y][0] += 1
    max_height, max_h_val = max_bomb_set(height)
    max_width, max_w_val = max_bomb_set(width)
    ans = max_h_val + max_w_val
    for hh in max_height:
        for ww in max_width:
            if (hh, ww) not in target:
                return ans
    return ans - 1


if __name__ == '__main__':
    print(main())