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

# -*- coding: utf-8 -*-
import numpy as np
n = int(input())
nums = input().split()
nums = [int(nums[i]) for i in range(0, len(nums))]
l = len(nums)
res = nums[:]

while l > 1:
    fst = res[0]
    tmp = res[1:]
    res = []
    flg = False
    find = -1
    # even
    if fst % 2 == 0:
        for i in range(0, len(tmp)):
            if flg == False and tmp[i] % 2 == 0:
                find = fst + tmp[i]
                flg = True
            else:
                res.append(tmp[i])
        if flg:
            res.append(find)
    else:
        for i in range(0, len(tmp)):
            if flg == False and tmp[i] % 2 == 1:
                find = fst + tmp[i]
                flg = True
            else:
                res.append(tmp[i])
        if flg:
            res.append(find)
    if flg == False and len(tmp) != 1:
        res = []
        res.append(fst)
        fst = tmp[0]
        tmp = tmp[1:]
        # even
        if fst % 2 == 0:
            for i in range(0, len(tmp)):
                if flg == False and tmp[i] % 2 == 0:
                    find = fst + tmp[i]
                    flg = True
                else:
                    res.append(tmp[i])
            if flg:
                res.append(find)
        else:
            for i in range(0, len(tmp)):
                if flg == False and tmp[i] % 2 == 1:
                    find = fst + tmp[i]
                    flg = True
                else:
                    res.append(tmp[i])
            if flg:
                res.append(find)
    if flg == False:
        print ("NO")
        quit()
    else:
        if l == len(res):
            print("something wrong!")
            print(res)
            quit()
        l = len(res)
print("YES")

### FIXED CODE ###

# -*- coding: utf-8 -*-
import numpy as np
n = int(input())
nums = input().split()
nums = [int(nums[i]) for i in range(0, len(nums))]

odd = 0
even = 0
for i in range(0, len(nums)):
    if nums[i] % 2 == 0:
        even += 1
    else:
        odd += 1
if odd % 2 == 0:
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

s = input()
q = int(input())
ans = s
for i in range(q):
    t = input().split()
    if t[0] == "1":
        ans = ans[::-1]
    elif t[0] == "2":
        _, f, c = t
        if f == "1":
            ans = c + ans
        elif f == "2":
            ans += c
print(ans)


### FIXED CODE ###

from collections import deque

s = input()
q = int(input())
r = 1
top = deque()
top.append(s)
for _ in range(q):
    inp = input()
    if inp[0] == "1":
        r *= -1
    else:
        _, f, c = inp.split()
        if f == "1" and r == -1 or f == "2" and r == 1:
            top.append(c)
        else:
            top.appendleft(c)
ans = "".join(top)
print(ans if r == 1 else ans[::-1])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N, M = MI()
adj = [list() for _ in range(3 * N)]
for _ in range(M):
    u, v = map(lambda s: int(s) - 1, input().split())
    adj[u].append((v + N) % (3 * N))
    adj[u + N].append((v + 2 * N) % (3 * N))
    adj[u + 2 * N].append((v + 3 * N) % (3 * N))
S, T = map(lambda s: int(s) - 1, input().split())

st = [(S, 0)]
seen = {S}
while len(st) > 0:
    v, cnt = st.pop()
    if v == T:
        print(cnt // 3)
        exit(0)
    for nxt in adj[v]:
        if nxt not in seen:
            st.append((nxt, cnt + 1))
print(-1)

### FIXED CODE ###

import sys
sys.setrecursionlimit(300000)
from collections import deque

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N, M = MI()
adj = [list() for _ in range(N)]
for _ in range(M):
    u, v = map(lambda s: int(s) - 1, sys.stdin.readline().split())
    adj[u].append(v)
S, T = map(lambda s: int(s) - 1, sys.stdin.readline().split())

q = deque([(0, S, 0)])
seen = {S}
while len(q) > 0:
    dim, v, cnt = q.popleft()
    if v == T and dim == 0:
        print(cnt // 3)
        exit(0)
    ndim = (dim + 1) % 3
    for nxt in adj[v]:
        if (ndim * N + nxt) not in seen:
            q.append((ndim, nxt, cnt + 1))
            seen.add(ndim * N + nxt)
print(-1)
### BUGGY CODE ###

import bisect
n = int(input())

a = [int(input()) for i in range(n)]

color = [a[0]]

for i in range(1,n):
    idx = bisect.bisect_left(color,a[i])
    if idx == 0:
        color.insert(0,a[i])
    else:
        color[idx-1] = a[i]
        
print(len(color))

### FIXED CODE ###

import sys
input = sys.stdin.readline

from collections import deque

import bisect
n = int(input())

a = [int(input()) for i in range(n)]

#color = [a[0]]

d = deque()
d.appendleft(a[0])

for i in range(1,n):
    idx = bisect.bisect_left(d,a[i])
    if idx == 0:
        d.appendleft(a[i])
    else:
        d[idx-1] = a[i]
        
print(len(d))
### BUGGY CODE ###

from collections import defaultdict

n, k = map(int, input().split())
k2 = k * 2
requires = defaultdict(lambda: [0, 0])
for i in range(n):
    x, y, c = input().split()
    x, y = int(x), int(y)
    rx, ry = x % k2, y % k2
    b = c == 'B'
    if rx > k:
        if ry > k:
            rx -= k
            ry -= k
        else:
            rx -= k
            b = not b

    requires[rx, ry][b] += 1

ans = 0
for dx in range(k):
    for dy in range(k):
        cnt_w, cnt_b = 0, 0
        for (x, y), (w, b) in requires.items():
            f = ((x + dx) // k + (y + dy) // k) & 1
            if f:
                cnt_w += b
                cnt_b += w
            else:
                cnt_w += w
                cnt_b += b
        ans = max(ans, cnt_b, cnt_w)
print(ans)


### FIXED CODE ###

from itertools import accumulate

n, k = map(int, input().split())
k2 = k * 2
req_b = [[0] * k for _ in range(k)]
req_w = [[0] * k for _ in range(k)]
bc, wc = 0, 0
for i in range(n):
    x, y, c = input().split()
    x, y = int(x), int(y)
    rx, ry = x % k2, y % k2
    b = c == 'B'
    if rx >= k:
        rx -= k
        if ry >= k:
            ry -= k
        else:
            b = not b
    elif ry >= k:
        ry -= k
        b = not b
    if b:
        req_b[rx][ry] += 1
        bc += 1
    else:
        req_w[rx][ry] += 1
        wc += 1

req_b[0] = list(accumulate(req_b[0]))
req_w[0] = list(accumulate(req_w[0]))

for i in range(1, k):
    req_b[i][0] += req_b[i - 1][0]
    req_w[i][0] += req_w[i - 1][0]
    for j in range(1, k):
        req_b[i][j] += req_b[i][j - 1] + req_b[i - 1][j] - req_b[i - 1][j - 1]
        req_w[i][j] += req_w[i][j - 1] + req_w[i - 1][j] - req_w[i - 1][j - 1]

ans = 0
for dx in range(k):
    dxk_b = req_b[dx][-1]
    dxk_w = req_w[dx][-1]
    for dy in range(k):
        b1 = req_b[dx][dy]
        b2 = bc - req_b[k - 1][dy] - dxk_b + b1
        w1 = req_w[dx][dy]
        w2 = wc - req_w[k - 1][dy] - dxk_w + w1
        b, w = b1 + b2, w1 + w2
        ans = max(ans, b + wc - w, w + bc - b)
        # print(dx, dy, b, w, b + wc - w, w + bc - b)
print(ans)
### BUGGY CODE ###

#入力取得
from fractions import Fraction
import sys
sys.setrecursionlimit(15000)

def fibMul(fn1, fn2):
  a = fn1[0]
  b = fn1[1]
  c = fn2[0]
  d = fn2[1]
  return (a*c + 5*b*d, a*d + b*c)

def fibExp(fn, n):
  if (n == 0):
    return (Fraction(1), Fraction(1));
  if (n % 2 == 0):
    return fibExp(fibMul(fn, fn), n / 2);
  return fibMul(fn, fibExp(fn, n - 1));

def fibMin(fn1, fn2):
  a = fn1[0]
  b = fn1[1]
  c = fn2[0]
  d = fn2[1]
  return (a - c, b - d)

def fibMain(n):
  fibNum1 = (Fraction(1, 2), Fraction( 1, 2))
  fibNum2 = (Fraction(1, 2), Fraction(-1, 2))

  fibNum3 = fibMin(fibExp(fibNum1, n), fibExp(fibNum2, n))
  fibNum4 = (Fraction(0, 1), Fraction(1, 5))
  return fibMul(fibNum3, fibNum4)

def fib(n):
  return fibMain(n)[0].numerator





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

a= []

for i in range(M):
    a.append(int(input()))

l = ["1"] * (N + 1)

for a_ele in a:
    l[a_ele] = "0"

l = ''.join(l)

# print(l)

if '00' in l:
    print(0)

else:
    l_arr = l.split('0')
    result = 1
    for l_ele in l_arr:
        result *= fib(len(l_ele))
        result = result % 1000000007

    print(result)


### FIXED CODE ###

def fib(n):
    if n <= 1:
        return n
    result = [1, 0, 0, 1]
    matrix = [1, 1, 1, 0]
    while n > 0:
        if n % 2:
            result = mul(matrix, result)
        matrix = mul(matrix, matrix)
        n //= 2
    return result[2]

def mul(a, b):
    return [a[0]*b[0] + a[1]*b[2],
            a[0]*b[1] + a[1]*b[3],
            a[2]*b[0] + a[3]*b[2],
            a[2]*b[1] + a[3]*b[3]]





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

a= []

for i in range(M):
    a.append(int(input()))

l = ["1"] * (N + 1)

for a_ele in a:
    l[a_ele] = "0"

l = ''.join(l)

# print(l)

if '00' in l:
    print(0)

else:
    l_arr = l.split('0')
    result = 1
    for l_ele in l_arr:
        result *= fib(len(l_ele))

        if result > 1000000007:
            result = result % 1000000007

    result = result % 1000000007

    print(result)
### BUGGY CODE ###

def main():
    # 区間更新・一点取得の加法BIT
    class BIT():
        def __init__(self, n):
            self.n = n
            self.maxbit = 2**(len(bin(n))-3)
            self.bit = [0]*(n+1)

        # 初期化する
        def make_bit(self, a):
            n, bit = self.n, self.bit
            for i, j in enumerate(a):
                x, y = i+1, i+2
                while x < n+1:
                    bit[x] += j
                    x += x & (-x)
                while y < n+1:
                    bit[y] -= j
                    y += y & (-y)

        # 区間[i:j]に値vを足す
        def add(self, i, j, v):
            x, y, n, bit = i+1, j+1, self.n, self.bit
            while x < n+1:
                bit[x] += v
                x += x & (-x)
            while y < n+1:
                bit[y] -= v
                y += y & (-y)

        # 位置iの値を出力する
        def output(self, i):
            ret, x, bit = 0, i+1, self.bit
            while x > 0:
                ret += bit[x]
                x -= x & (-x)
            return ret

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

    for cnt in range(min(k, 50)):
        ans = []
        bit = BIT(n)
        for i in range(n-1, -1, -1):
            bit.add(max(i-a[i], 0), min(i+a[i]+1, n), 1)
        for i in range(n):
            ans.append(bit.output(i))
        a = ans

    print(*ans)


main()


### FIXED CODE ###

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

    n, k = map(int, input().split())
    a = list(map(int, input().split()))
    
    for cnt in range(min(k, 41)):
        ans = []
        bit = [0]*(n+1)
        for i, j in enumerate(a):
            x, y = max(i-j, 0)+1, min(i+j+1, n)+1
            while x < n+1:
                bit[x] += 1
                x += x & (-x)
            while y < n+1:
                bit[y] -= 1
                y += y & (-y)
        for i in range(n):
            ret, x = 0, i+1
            while x > 0:
                ret += bit[x]
                x -= x & (-x)
            ans.append(ret)
        a = ans

    print(*ans)


main()
### BUGGY CODE ###

n=int(input())
a = list(map(lambda x:format(x,'060b'),map(int,input().split())))

p = 10**9+7
ans = 0

for i in range(60):
    one = 0
    for j in range(n):
        if a[j][59-i]=='1':
            one += 1
    ans += pow(2,i,p)*one*(n-one)

print(ans%p)


### FIXED CODE ###

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

p = 10**9+7
ans = 0
for i in range(60):
    x = 1<<i
    one = sum(1 for j in a if j&x)
    ans += pow(2,i,p)*one*(n-one)

print(ans%p)
### BUGGY CODE ###

n = int(input())

dic = {}
for i in range(n):
    m = int(input())
    if m not in dic.keys():
        dic[m] = 0
    dic[m] += 1

dic_list = list(dic.values())
ans = 0
for i in range(len(dic_list)):
    if dic_list[i] % 2 == 1:
        ans += 1

print(ans)


### FIXED CODE ###

import collections

n = int(input())
a = list()

for i in range(n):
    a.append(int(input()))

dic = collections.Counter(a)
    
dic_list = list(dic.values())
ans = 0
for i in range(len(dic_list)):
    if dic_list[i] % 2 == 1:
        ans += 1

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

def mygets():
    return list(map(int, input().split()))

n, x = mygets()
a = mygets()

b1 = a.copy()
b2 = a.copy()

ans = sum(a)

for i in range(1, n):
    for j, v in enumerate(a):
        b2[j] = min(v, b1[(j + n - 1) % n])
    ans = min(ans, sum(b2) + i * x)
    b1, b2 = b2, b1

print(ans)

### FIXED CODE ###

def mygets():
    return list(map(int, input().strip().split(' ')))

n, x = mygets()
a = mygets()

b1 = a

ans = sum(a)

def f(k, u):
    j = k - 1
    if j < 0:
        j = n - 1
    w = b1[j]
    if u < w:
        return u
    return w

for i in range(1, n):
    b2 = [f(k, u) for k, u in enumerate(a)]
    ans = min(ans, sum(b2) + i * x)
    b1 = b2

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

import sys
from heapq import heappush, heappop

inf = float('inf')

n, x, y = map(int, sys.stdin.readline().split())
g = [[] for _ in range(n)]
for i in range(n-1):
    g[i].append(i+1)
    g[i+1].append(i)
g[x-1].append(y-1)
g[y-1].append(x-1)

def dijkstra(i):
    dist = [inf] * n
    dist[i] = 0
    q = [(0, i)]
    visited = set()

    while q:
        d, x = heappop(q)
        if x in visited:
            continue
        dist[x] = d
        visited.add(x)
        for y in g[x]:
            if y in visited:
                continue
            heappush(q, (d+1, y))
    return dist
    
def main():
    res = [0] * (n + 1)
    for i in range(n):
        dist = dijkstra(i)
        for d in dist:
            res[d] += 1
    for c in res[1:-1]:
        print(c // 2)

if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
from itertools import combinations

n, x, y = map(int, sys.stdin.readline().split())
    
def main():
    res = [0] * (n + 1)
    for i, j in combinations(range(1, n+1), 2):
        d = min(j - i, abs(i - x) + 1 + abs(j - y))
        res[d] += 1
        
    for i in range(1, n):
        print(res[i])

if __name__ == "__main__":
    main()
### BUGGY CODE ###

n=int(input())
x,y,h=[0]*n,[0]*n,[0]*n
for i in range(n):
  x[i],y[i],h[i]=map(int,input().split())
mn_h=min(h)
mx_h=max(h)
for H in range(mn_h-210,mx_h+210):
  for C_x in range(101):
    for C_y in range(101):
      for i in range(n):
        if not h[i]==max(H-abs(x[i]-C_x)-abs(y[i]-C_y),0):
          break
      else:
        print(C_x,C_y,H)

### FIXED CODE ###

n=int(input())
x,y,h=[0]*n,[0]*n,[0]*n
for i in range(n):
  x[i],y[i],h[i]=map(int,input().split())
mn_h=min(h)
mx_h=max(h)
for C_x in range(101):
  for C_y in range(101):
    for i in range(n):
      H=h[i]+abs(x[i]-C_x)+abs(y[i]-C_y)
      if H>0:
        if all(max(H-abs(x[j]-C_x)-abs(y[j]-C_y),0)==h[j] for j in range(n)):
          print(C_x,C_y,H)
          exit()
### BUGGY CODE ###

n,k = map(int, input().split())
tmpNum = n
subtraction = n
if n % k == 0:
  print(0)
else:
  while(1):
    subtraction = abs(subtraction-k)
    if subtraction < tmpNum:
      tmpNum = subtraction
    else:
      break
  print(tmpNum)

### FIXED CODE ###

n,k = map(int, input().split())
tmpNum = n
subtraction = n
if n % k == 0:
  print(0)
else:
  tmp = int(n/k)
  subtraction = n - (tmp*k)
  while(1):
    subtraction = abs(subtraction-k)
    if subtraction < tmpNum:
      tmpNum = subtraction
    else:
      break
  print(tmpNum)
### BUGGY CODE ###



if __name__ == "__main__":
    U = input()
    A = input().split()

    for i in A:
        if A.count(i) > 1:
            ret  = "NO"
            print(ret)
            exit(0)   
    ret = "YES"

    print(ret)


### FIXED CODE ###



if __name__ == "__main__":
    U = input()
    A = input().split()

    A_uni = set(A)

    if len(A) != len(A_uni):
        ret  = "NO"
    else:
        ret = "YES"

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

L, R = map(int, input().split())
MOD = 2019
# L = 2020
# R = 2040
diff = (R - L) % MOD
new_L = L % MOD
new_R = R + diff

ans = L*R%MOD
for i in range(L, R):
    for j  in range(i+1, R+1):
        if ans > i*j%MOD:
            ans = i*j%MOD
print(ans)


### FIXED CODE ###

L, R = map(int, input().split())
MOD = 2019
ans = L*R%MOD
for i in range(L, R):
    for j  in range(i+1, R+1):
        if ans > i*j%MOD:
            ans = i*j%MOD
        if ans == 0:
            break
    if ans == 0:
        break
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)

#%%
def dfs(gr,li):
    st = []
    seen = set()
    st.append([0,-1])
    while(st):
        x,fr = st.pop()
        if(x in seen):continue
        if(fr != -1):
            li[x]+=li[fr]
        ns = [[i,x] for i in gr[x]]
        st[0:0] = ns
        seen.add(x)

#%%
def main():
    N,Q = [int(x) for x in input().split()]
    li = [0]*N
    gp = [[] for _ in range(N)]
    for _ in range(N-1):
        a,b = [int(x) for x in input().split()]
        gp[a-1].append(b-1)
        gp[b-1].append(a-1)

    for _ in range(Q):
        p,x = [int(x) for x in input().split()]
        li[p-1] += x

    dfs(gp,li)
    print(*li)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N,Q = [int(x) for x in input().split()]
    li = [0]*N
    gp = [[] for _ in range(N)]
    for _ in range(N-1):
        a,b = input().split()
        a = int(a)
        b = int(b)
        gp[a-1].append(b-1)
        gp[b-1].append(a-1)

    for _ in range(Q):
        p,x = input().split()
        li[int(p)-1] += int(x)

    st = []
    seen = set()
    st.append(0)
    while(st):
        x = st.pop()
        if(x in seen):continue
        seen.add(x)
        for i in gp[x]:
            if(i in seen):continue
            li[i]+=li[x]
            st.append(i)
    print(*li)

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

from scipy.misc import comb

N = int(input())
num_list = list(map(int, input().split()))
num_set = set(num_list)

# 全数あるときの組み合わせ
ans_dict_1 = {}
# 1個抜いたときの組み合わせ
ans_dict_2 = {}

for i in num_set:
  num_counter = num_list.count(i)
  ans_dict_1[i] = comb(num_counter,2,exact=True)
  ans_dict_2[i] = comb(num_counter-1,2,exact=True)

total = sum(ans_dict_1.values())

for i in num_list:
  print(total - ans_dict_1[i] + ans_dict_2[i])

### FIXED CODE ###

from scipy.misc import comb
from collections import Counter
import datetime

N = int(input())
num_list = list(map(int, input().split()))
# num_set = set(num_list)
num_dict = {}

num_counter = Counter(num_list)
  
# 全数あるときの組み合わせ
ans_dict_1 = {}
# 1個抜いたときの組み合わせ
ans_dict_2 = {}
rap_2 = datetime.datetime.now()
for k, v in num_counter.most_common():
  ans_dict_1[k] = comb(v,2,exact=True)
  ans_dict_2[k] = comb(v-1,2,exact=True)

total = sum(ans_dict_1.values())

for i in num_list:
  print(total - ans_dict_1[i] + ans_dict_2[i])
### BUGGY CODE ###

N = int(input())
S = input()
R_indices = []
G_indices = []
B_indices = []
for i, s in enumerate(S):
    if s == 'R':
        R_indices.append(i)
    elif s == 'G':
        G_indices.append(i)
    elif s == 'B':
        B_indices.append(i)

count = len(R_indices) * len(G_indices) * len(B_indices)

for r in R_indices:
    for g in G_indices:
        for b in B_indices:
            i, j ,k = sorted([r, g, b])
            if j - i == k - j:
                count -=  1

print(count)

### FIXED CODE ###

N = int(input())
S = input()
moji = {'R', 'G', 'B'}

count = 0
for j in range(1, N-1):
    sj = S[j]
    diff_m = moji - {sj}
    rem_moji = list(diff_m)
    for mi, mj in zip(rem_moji, rem_moji[::-1]):
        ci = S.count(mi, 0, j)
        ck = S.count(mj, j+1, N)
        count += ci * ck

    l = min([j+1, N - j])
    for d in range(1, l):
        si = S[j-d]
        sk = S[j+d]
        if si != sj and sj != sk and sk != si:
            count -= 1

print(count)
### BUGGY CODE ###

import itertools
N = int(input())
A = [[int(_) for _ in input().split()] for _ in range(N)]
ans = sum(sum(a) for a in A) // 2
seen = set()
for i in range(N):
    for j in range(i + 1, N):
        for k in range(N):
            if A[i][j] > A[i][k] + A[j][k]:
                print(-1)
                exit()
            elif k == i or i == j or j == k:
                continue
            elif A[i][j] == A[i][k] + A[j][k]:
                ans -= A[i][j]
                break
print(ans)


### FIXED CODE ###

import itertools
N = int(input())
A = [[int(_) for _ in input().split()] for _ in range(N)]
ans = sum(sum(a) for a in A) // 2
seen = set()
for i in range(N):
    for j in range(i + 1, N):
        for k in range(N):
            if A[i][j] > A[i][k] + A[j][k]:
                print(-1)
                exit()
            elif k == i or i == j or j == k:
                continue
            elif A[i][j] == A[i][k] + A[j][k]:
                ans -= A[i][j]
                break
print(ans)
### BUGGY CODE ###

from collections import Counter
h, w, m = map(int, input().split())
blist = [list(map(int, input().split())) for _ in range(m)]

rowdict = Counter([blist[i][0] for i in range(m)])
coldict = Counter([blist[i][1] for i in range(m)])

maxr = rowdict.most_common()[0][1]
maxr_keys = []
for i in rowdict.most_common():
    if i[1] == maxr:
        maxr_keys.append(i[0])
    else:
        break
maxc = coldict.most_common()[0][1]
maxc_keys = []
for i in coldict.most_common():
    if i[1] == maxc:
        maxc_keys.append(i[0])
    else:
        break

for i in maxr_keys:
    for j in maxc_keys:
        if [i, j] not in blist:
            print(maxr + maxc)
            break
    else:
        continue
    break
else:
    print(maxr + maxc - 1)


### FIXED CODE ###

from collections import Counter
h, w, m = map(int, input().split())
blist = [list(map(int, input().split())) for _ in range(m)]

blist_set = set(map(tuple, blist))

rowdict = Counter([blist[i][0] for i in range(m)])
coldict = Counter([blist[i][1] for i in range(m)])

maxr = rowdict.most_common()[0][1]
maxr_keys = []
for i in rowdict.most_common():
    if i[1] == maxr:
        maxr_keys.append(i[0])
    else:
        break
maxc = coldict.most_common()[0][1]
maxc_keys = []
for i in coldict.most_common():
    if i[1] == maxc:
        maxc_keys.append(i[0])
    else:
        break

for i in maxr_keys:
    for j in maxc_keys:
        if (i, j) not in blist_set:
            print(maxr + maxc)
            break
    else:
        continue
    break
else:
    print(maxr + maxc - 1)
### BUGGY CODE ###

import sys
import bisect

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
A = [ri() for _ in range(N)]
l = []
for a in A:
    i = bisect.bisect_left(l, a)
    if i == 0:
        l = [a] + l
    else:
        l[i-1] = a

print(len(l))
#39


### FIXED CODE ###

import sys
import bisect

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N = ri()
INF = 10 ** 18
A = [10 ** 10 - ri() for _ in range(N)]
dp = [INF] * (N+1)
for a in A:
    i = bisect.bisect_right(dp, a)
    dp[i] = a

print(bisect.bisect_left(dp, INF))
#39 答え見る
### BUGGY CODE ###

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

tree = {}
for i in range(n-1):
    a, b = map(int, input().split())
    tree[a] = tree.get(a, []) + [b]

op = {i: 0 for i in range(1, n+1)}
for i in range(q):
    p, x = map(int, input().split())
    op[p] = op[p] + x

for node in op.keys():
    if node in tree:
        for i in tree[node]:
            op[i] += op[node]

print(*op.values())

### FIXED CODE ###

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

tree = [[] for i in range(n+1)]
for i in range(n-1):
    a, b = map(int, input().split())
    tree[a].append(b)

op = [0] * (n+1)
for i in range(q):
    p, x = map(int, input().split())
    op[p] += x

for root, reaf in enumerate(tree):
    for i in reaf:
        op[i] += op[root]

print(*op[1:])