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

n = int(input())
a = [int(stdins) for stdins in input().split()]

a.sort()

ans = n
divisibles = [False for i in range(n)]
for i in range(n):
    divisible = False
    for j in range(n):
        if i == j:
            continue
        elif a[i] < a[j]:
            break
        elif a[i] % a[j] == 0:
            ans -= 1
            divisibles[i] = True
            break

print(ans)


### FIXED CODE ###

# ABC170

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

a.sort()
a_max = max(a)
dp = [True for _ in range(a_max+1)]

ans = 0
for i in range(n):
    if dp[a[i]]:
        for j in range(0, a_max+1, a[i]):
            dp[j] = False
        if i > 0:
            if a[i] == a[i-1]:
                continue
        if i < n-1:
            if a[i] == a[i+1]:
                continue
        ans += 1

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

def DP():
  
  n,m=map(int,input().split())
  dp=[0]*(m+2)

  for i in range(n):  #商品を一つずつ見ていく。
    w,v=(map(int,input().split()))
    for j in range(m+1,w,-1): #w~(限界-w)までのdpの箱に入れていく。(例)w,m=3,8なら3~5
      if (dp[j-w]+v)>dp[j]:
        dp[j]=dp[j-w]+v
      else:
        dp[j]=dp[j]
  return max(dp) 
print(DP())




### FIXED CODE ###

def DP():
    n,W = map(int, input().split(' '))
    WV = (map(int, input().split(' ')) for _ in range(n))
    dp = [0] * (W+1)

    for w, v in WV:
        for j in range(W, w-1, -1):
            DP = dp[j-w] + v
            if dp[j] < DP:
                dp[j] = DP
    return max(dp)
print(DP())
### BUGGY CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    L = 0
    print(L, flush=True)
    Ls = input()
    if Ls == "Vacant":
        exit()
    else:
    U = N-1
    print(U, flush=True)
    Us = input()
    if Us == "Vacant":
        exit()
    for i in range(18):
        mid = (U+D)//2
        if mid%2==1:
            mid-=1
        print(mid, flush=True)
        ms = input()
        if ms == "Vacant":
            exit()
        if Ls==ms:
            L=mid
        if Us==ms:
            U=mid

if __name__ == '__main__':
    main()

### FIXED CODE ###

#!/usr/bin python3
# -*- coding: utf-8 -*-

import sys

def main():
    N = int(input())
    L = 0
    print(L)
    sys.stdout.flush()
    Ls = input()
    if Ls == "Vacant":
        exit()
    U = N-1
    print(U)
    sys.stdout.flush()
    Us = input()
    if Us == "Vacant":
        exit()
    for _ in range(18):
        mid = (U+L)//2
        if mid%2==1:
            mid-=1
        if mid==L:
            mid+=1
        print(mid)
        sys.stdout.flush()
        ms = input()
        if ms == "Vacant":
            exit()
        if Ls==ms:
            L=mid
        if Us==ms:
            U=mid

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

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def main():
    n = inp()
    res = 1
    for i in range(1,n+1):
        res *= i%mod
    print(res%mod) 
if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

def main():
    n = inp()
    res = 1
    for i in range(1,n+1):
        res = res * i % mod
    print(res%mod) 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

n = int(input())

m_sum = 0
for i in range(1, n):
    m_sum += i
print(m_sum)

### FIXED CODE ###

n = int(input())

m_sum = 0
print(int(n*(n-1)//2))
### BUGGY CODE ###

R,G,B,N = map(int, input().split())
count = 0
for r in range(N+1):
    for g in range(N+1-r):
        if (N-R*r-G*g) % B ==0 and -1 < N-R*r-G*g :
            count += 1
print(count)

### FIXED CODE ###

R,G,B,N = map(int, input().split())
count = 0
for r in range(N//R +1):
    for g in range((N-r*R)//G + 1):
        if (N-R*r-G*g) % B ==0:
            count += 1

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

# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))
from math import sqrt
from itertools import combinations
import random
from fractions import gcd
N = int(input())
def primesd(N):
    P = [2]
    L = (N-1)//2
    searched = [False]*(L+1)
    for i in range(1, L+1):
        if searched[i]:
            continue
        j = i*2+1
        P.append(j)
        searched[i::j] = [True]*(((L-i)//j)+1)
    return P

P = primesd(int(sqrt(30000)))
S = [True]*30001
S[:2] = [False]*2

for p in P:
    i = p
    while i <= 30000:
        S[i] = False
        i *= p

for a, b in combinations(P, 2):
    S[a*b] = False

for a, b, c in combinations(P, 3):
    if a*b*c < 30000:
        S[a*b*c] = False

for a, b, c, d in combinations(P, 4):
    if a*b*c*d < 30000:
        S[a*b*c*d] = False

for a, b, c, d, e in combinations(P, 5):
    if a*b*c*d*e < 30000:
        S[a*b*c*d*e] = False

numbers = [i for i, s in enumerate(S) if s==True]

count = 0
while True:
    sample = random.sample(numbers, N-1)
    sum_ = sum(sample)
    if sum_ % 7 != 0:
        continue
    elif any([s%7!=0 for s in sample]):
        sum_ += 7
        for s in sample:
            if gcd(s, sum_-s) == 1:
                break
        else:
            sample += [7]
            print(*sample)
            break

### FIXED CODE ###

# -*- coding: utf-8 -*-
def inpl(): return tuple(map(int, input().split()))

N = int(input())
if N == 3:
    print("2 5 63")
    exit()
elif N == 4:
    print("2 5 20 63")
    exit()
elif N == 5:
    print("7 1580 9438 11373 22962")
    exit()

numbers = []

for k in range(0, 5000):
    numbers.extend([6*k+2, 6*k+3, 6*k+4, 6*k+6])

ans = numbers[:N]
S = sum(ans)


if S%6 == 0:
    pass
elif S%6 == 2:
    del ans[4]
    ans.append((ans[-1]//6 + 1)*6)
elif S%6 == 3:
    del ans[5]
    ans.append((ans[-1]//6 + 1)*6)
else:
    x, y = (ans[-1]//6)*6+4, (ans[-1]//6)*6+10
    ans.append(x if x > ans[-1] else y)
    del ans[5]
print(*ans)
### BUGGY CODE ###

import itertools
N=int(input())
word="0123456789"
number=["".join(i) for i in itertools.product(word,repeat=3)]

S=list(input())
ans=0
for i in number:
    count=0

    for s in range(N):
        if i[count]==S[s]:
            count+=1
            if count==3:
                ans+=1
                break

print(ans)




### FIXED CODE ###

def main():
  N = int(input())
  S = list(map(int,input()))
  ans = 0
  for i in range(10):
    for j in range(10):
      for k in range(10):
        flg = False
        flg2 = False
        for x in range(N):
          if flg2:
            break
          if not flg:
            if S[x] == i:
              flg = True
          else:
            if S[x] == j:
              flg2 = True
              if k in S[x+1:]:
                ans +=1
  print(ans)
main()
### BUGGY CODE ###

N, K = map(int,input().split())
p = list(map(int,input().split()))
ma = sum(p[0:K]) 
for i in range(N-K):
  newma = sum(p[i+1:K+i+1])
  if ma < newma:
    ma = newma
print((ma+K)/2)

### FIXED CODE ###

N, K = map(int,input().split())
p = list(map(int,input().split()))
ma = sum(p[0:K]) 
newma = ma
for i in range(N-K):
  newma = newma + p[K+i] - p[i]
  if ma < newma:
    ma = newma
print((ma+K)/2)
### BUGGY CODE ###

from math import gcd, sqrt, ceil
from functools import reduce

def sieve(n):
    A = list(range(n+1))
    for i in range(2, n+1 ,2):
        A[i] = 2
    for j in range(3, ceil(sqrt(n+1))+1, 2)[::-1]:
        for i in range(j, n+1, j):
            A[i] = j
    return A

def factorize(n, A):
    factors = set()
    while n != 1:
        f = A[n]
        factors.add(f)
        n //= f
    return factors

_, *aa = map(int, open(0).read().split())

def main(aa):
    pair_co = True
    max_factors = set()
    A = sieve(10**6)
    for a in aa:
        factors = factorize(a, A)
        new_max_factors = max_factors | factors
        if len(new_max_factors) < len(max_factors) + len(factors):
            pair_co = False
            break
        max_factors = new_max_factors
    if pair_co:
        return 'pairwise coprime'
    elif reduce(gcd, aa) == 1:
        return 'setwise coprime'
    else:
        return 'not coprime'

print(main(aa))

### FIXED CODE ###

from math import gcd, sqrt, ceil
from functools import reduce

def sieve(n):
    A = list(range(n+1))
    for i in range(2, n+1 ,2):
        A[i] = 2
    for j in range(3, ceil(sqrt(n+1))+1, 2)[::-1]:
        for i in range(j, n+1, j):
            A[i] = j
    return A

def factorize(n, A):
    factors = set()
    while n != 1:
        f = A[n]
        factors.add(f)
        n //= f
    return factors

_, *aa = map(int, open(0).read().split())

def main(aa):
    pair_co = True
    A = sieve(10**6)
    all_factors = [0] * (10**6+1)
    for a in aa:
        factors = factorize(a, A)
        for factor in factors:
            if all_factors[factor]:
                pair_co = False
                break
            else:
                all_factors[factor] = 1
        if not pair_co:
            break
    if pair_co:
        return 'pairwise coprime'
    elif reduce(gcd, aa) == 1:
        return 'setwise coprime'
    else:
        return 'not coprime'

print(main(aa))
### BUGGY CODE ###

import numpy as np

N = int(input())
arr = np.array(list(map(int, input().split())))

Q = int(input())

for i in range(Q):
    B, C = list(map(int, input().split()))
    arr[arr == B] = C
    print(arr.sum())


### FIXED CODE ###

import numpy as np
from collections import defaultdict

N = int(input())

arr = np.array(list(map(int, input().split())))
unique, cnts = np.unique(arr, return_counts=True)

counts = defaultdict(int)
sum = arr.sum()

for key, val in zip(unique, cnts):
    counts[key] = val

Q = int(input())

for i in range(Q):
    B, C = list(map(int, input().split()))
    counts[C] += counts[B]
    sum += counts[B] * (C - B)
    counts[B] = 0
    print(sum)
### BUGGY CODE ###

def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and int(A[j]) > int(v):
            A[j + g] = A[j]
            j = j - g
            cnt += 1
            A[j + g] = v

def shellSort(A, n):
    global m, G
    for i in range(0, m): 
        insertionSort(A, n, G[i])

n = int(input())
A = []
for i in range(0, n):
    A.append(int(input()))

G = []
h = 1
for i in range(1, 999999):
    if h > n:
        break
    G.append(h)
    h = 3 * h + 1

G.reverse()

cnt = 0
m = len(G)
shellSort(A, n)
'''
m = 2
G = (4,1)
shellSort(A, n)
'''

print(m)
print(" ".join(map(str, G)))
print(cnt)
for i in range(0, n):
    print(A[i])

### FIXED CODE ###

def insertionSort(A, n, g):
    global cnt
    for i in range(g, n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j + g] = A[j]
            j = j - g
            cnt += 1
        A[j + g] = v

def shellSort(A, n):
    global m, G
    for i in range(0, m): 
        insertionSort(A, n, G[i])

n = int(input())
A = []
for i in range(0, n):
    A.append(int(input()))

G = []
h = 1
for i in range(1, 999999):
    if h > n:
        break
    G.append(h)
    h = 3 * h + 1

G.reverse()

cnt = 0
m = len(G)
shellSort(A, n)
'''
m = 2
G = (4,1)
shellSort(A, n)
'''

print(m)
print(" ".join(map(str, G)))
print(cnt)
for i in range(0, n):
    print(A[i])
### BUGGY CODE ###

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

ans = 0

for i ,Ai in enumerate(A,1):
  for j ,Aj in enumerate(A[i:],i+1):
    if i+Ai==j-Aj:
      #print(i,j)
      ans+=1
print(ans)

### FIXED CODE ###

import bisect
N = int(input())
A = list(map(int, input().split()))

ans = 0

R = []
for i ,Ai in enumerate(A,1):
  R.append(i+Ai)
R.sort()

L = []
for j ,Aj in enumerate(A,1):
  L.append(j-Aj)
L.sort()

for i in range(len(R)):
  r = bisect.bisect_right(L,R[i])
  l = bisect.bisect_left(L,R[i])
  ans+=r-l
 
print(ans)
### BUGGY CODE ###

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

now = 1

x = 2
while P >= x ** N:
    if P % x == 0:
        while P % (x ** N) == 0:
            now *= x
            P = P / (x ** N)
        while P % x == 0:
            P = P / x

    x += 1


print(now)

### FIXED CODE ###

n, p = map(int, input().split())
if n == 1:
    print(p)
else:
    for i in range(1, round(p**(1/n))+1):
        if p % i**n ==0:
            res = i
    print(res)
### BUGGY CODE ###

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

ls = []
for i in range(n):
  x = A[0]
  for j, a in enumerate(A[1:]):
    if j%2==0:
      x -= a
    else:
      x += a
  A.insert(n, A[0])
  A.pop(0)
  print(x)

### FIXED CODE ###

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

x = A[0]
for j, a in enumerate(A[1:]):
    if j%2==0:
      x -= a
    else:
      x += a
print(x)
for i in A[:-1]:
  x = 2*(i-x/2)
  print(int(x))
### BUGGY CODE ###

n,q = map(int, input().split())
str = input()
for i in range(q):
  l,r = map(int, input().split())
  sub_str = str[(l-1):r]
  count = 0
  for j in range(len(sub_str)):
    if (sub_str[j:j+2] == 'AC'):
      count += 1
  print(count)

### FIXED CODE ###

N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
  t[i + 1] = t[i] + (1 if S[i : i + 2] == 'AC' else 0)
for i in range(Q):
  l, r = map(int, input().split())
  print(t[r-1] - t[l-1])
### BUGGY CODE ###

import itertools

n, k = map(int, input().split())
xy = [tuple(map(int, input().split())) for i in range(n)]
ans = float("INF")
for a, b in itertools.combinations(xy, 2):
    for c, d in itertools.combinations(xy, 2):
        x1, x2 = sorted([a[0], b[0]])
        y1, y2 = sorted([c[1], d[1]])
        count = 0
        for x, y in xy:
            if x1 <= x <= x2 and y1 <= y <= y2:
                count += 1
        if count >= k:
            ans = min(ans, (x2 - x1) * (y2 - y1))
print(ans)

### FIXED CODE ###

import itertools

n, k = map(int, input().split())
xy = [tuple(map(int, input().split())) for i in range(n)]
ans = float("INF")
for a, b in itertools.combinations(xy, 2):
    for c, d in itertools.combinations(xy, 2):
        x1, x2 = a[0], b[0]
        y1, y2 = c[1], d[1]
        count = 0
        for x, y in xy:
            if min(x1, x2) <= x <= max(x1, x2) and min(y1, y2) <= y <= max(y1, y2):
                count += 1
        if count >= k:
            ans = min(ans, abs(x1 - x2) * abs(y1 - y2))
print(ans)
### BUGGY CODE ###

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

ans = 0
for i in range(N):
  j_start = ans + 1
  j_end = N - i
  for j in range(j_start, j_end):
    base = S[i:i+j]
    if base in S[i+j:]:
      ans = max(ans, j)


print(ans)

### FIXED CODE ###

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

ans = 0
for i in range(N):
  j_start = ans + 1
  j_end = (N - i) // 2 + 1
  for j in range(j_start, j_end):
    base = S[i:i+j]
    if base in S[i+j:]:
      ans = max(ans, j)
    else:
      break


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

import collections
N = int(input())
all = []
count = []
for i in range(N):
  count.append(collections.Counter(list(input())))
nsame = 0
for i in range(N):
  for j in range(i+1, N):
    if count[i] == count[j]:
      nsame = nsame + 1
print(nsame)

### FIXED CODE ###

N = int(input())
alldict = {}
nsame = 0
for i in range(N):
  tmp = list(input())
  tmp.sort()
  if ''.join(tmp) in alldict:
    alldict[''.join(tmp)] = alldict[''.join(tmp)] + 1
  else:
    alldict[''.join(tmp)] = 1

from operator import mul
from functools import reduce
def cmb(n,r):
    if n == 1:
        return 0
    r = min(n-r,r)
    if r == 0:
        return 1
    ov = reduce(mul, range(n, n-r, -1))
    un = reduce(mul, range(1, r+1))
    return ov // un

print(sum([cmb(i, 2) for i in alldict.values()]))
### BUGGY CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
MOD = 10 ** 9 + 7
A_max = A[K-1]
A_min = A[-K]
x = 1
count = 1
ans = A_max - A_min
for i in range(K,N):
    x = x * i // count
    #x %= MOD
    count += 1
    #print(x,i,count)
    A_max = (A[i] * x) 
    A_min = (A[-1*i-1] * x) 
    #print(A_max,A_min)
    ans = (ans + A_max - A_min) % MOD
print(ans)

### FIXED CODE ###

N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
mod = p = 10 ** 9 + 7

fact = [1]
fact_inv = [1]
for i in range(10**5+5):
    new_fact = fact[-1]*(i+1)%mod
    fact.append(new_fact)
    fact_inv.append(pow(new_fact,mod-2,mod))
 
 
def mod_comb_k(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod    

A_max = 0
A_min = 0
for i in range(N-K+1):
    A_max = (A_max + (A[(K-1)+i] * mod_comb_k((K+i-1),i,p))) % p   
    A_min = (A_min + (A[-1*(K+i)] * mod_comb_k((K+i-1),i,p))) % p
    #print(A_max,A_min,cmb((K+i),i,p))
ans = (A_max - A_min)
if ans < 0:
    ans = p + ans
ans %= p
print(ans)
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
mod = 10 ** 9 + 7

def main():
    result = 1
    i = -1
    j = -1
    used_area = 0

    A.sort(reverse=True)
    B.sort(reverse=True)

    for x in range(N * M, 0, -1):
        while i < N-1:
            if A[i+1] >= x:
                i += 1
            else:
                break

        while j < M-1:
            if B[j+1] >= x:
                j += 1
            else:
                break

        marked_row = False
        marked_col = False

        count_row = A[0:i+1].count(x)
        if count_row > 1:
            return(0)
        if count_row == 1:
            usable_row = 1
            marked_row = True
        else:
            usable_row = i+1

        count_col = B[0:j+1].count(x)
        if count_col > 1:
            return(0)
        if count_col == 1:
            usable_col = 1
            marked_col = True
        else:
            usable_col = j+1

        if marked_row or marked_col:
            usable_area = usable_row * usable_col
        else:
            usable_area = usable_row * usable_col - used_area

        if usable_area <= 0:
            return(0)

        result = result * usable_area % mod
        used_area += 1

    return(result)


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


### FIXED CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
mod = 10 ** 9 + 7

def main():
    result = 1
    i = -1
    j = -1
    used_area = 0

    A.sort(reverse=True)
    B.sort(reverse=True)

    for x in range(N * M, 0, -1):
        expanded_row = 0
        expanded_col = 0
        while i < N-1:
            if A[i+1] >= x:
                i += 1
                expanded_row += 1
            else:
                break

        while j < M-1:
            if B[j+1] >= x:
                j += 1
                expanded_col += 1
            else:
                break

        marked_row = False
        marked_col = False

        if expanded_row > 1:
            return(0)
        if expanded_row == 1:
            usable_row = 1
            marked_row = True
        else:
            usable_row = i+1

        if expanded_col > 1:
            return(0)
        if expanded_col == 1:
            usable_col = 1
            marked_col = True
        else:
            usable_col = j+1

        if marked_row or marked_col:
            usable_area = usable_row * usable_col
        else:
            usable_area = usable_row * usable_col - used_area

        # print('x:', x)
        # print('usable_row:', A[0:i+1])
        # print('usable_col:', B[0:j+1])
        # print('usable_area:', usable_area)

        if usable_area <= 0:
            return(0)

        result = result * usable_area % mod
        used_area += 1

    return(result)


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

N, W = map(int, input().split())
weight = []
value = []
for _ in range(N):
    w, v = map(int, input().split())
    weight.append(w)
    value.append(v)
value_sum = sum(value)
dp = [[float('inf') for _ in range(value_sum + 1)] for _ in range(N + 1)]
dp[0][0] = 0

for idx in range(N):
    for v in range(value_sum + 1):
        if value[idx] <= v:
            dp[idx + 1][v] = min(dp[idx][v], dp[idx][v - value[idx]] + weight[idx])
        else:
            dp[idx + 1][v] = dp[idx][v]
ans = 0
# print(dp)
for i in range(value_sum + 1):
    if dp[N][i] <= W:
        ans = i
print(ans)


### FIXED CODE ###

N, W = map(int, input().split())
weight = []
value = []
for _ in range(N):
    w, v = map(int, input().split())
    weight.append(w)
    value.append(v)
value_sum = sum(value)
dp = []
for _ in range(N + 1):
    dp_val = [float('inf') for _ in range(value_sum + 1)]
    dp.append(dp_val)
dp[0][0] = 0

for idx in range(N):
    for v in range(value_sum + 1):
        if value[idx] <= v:
            dp[idx + 1][v] = min(dp[idx][v], dp[idx][v - value[idx]] + weight[idx])
        else:
            dp[idx + 1][v] = dp[idx][v]
ans = 0
# print(dp)
for i in range(value_sum + 1):
    if dp[-1][i] <= W:
        ans = i
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
lr = []
for i in range(m):
    lr.append(list(map(int, input().split())))

canPass = [m] * n

for j in range(len(lr)):
    l = lr[j][0] - 1
    r = lr[j][1] - 1
    for k in range(l, r + 1):
        canPass[k] -= 1

ans = canPass.count(0)
print(ans)


### FIXED CODE ###

n, m = map(int, input().split())
l = 1
r = n
for i in range(m):
    a, b = map(int, input().split())
    l = max(l, a)
    r = min(r, b)

if l <= r:
    print(r - l + 1)
else:
    print(0)
### BUGGY CODE ###

N = int(input())
s = [list(sorted(input())) for i in range(N)]
s.sort()

ans = 0
for c in s:
        tmp = s.count(c)
        if tmp > 1:
                ans += tmp - 1

print(ans // 2)


### FIXED CODE ###

N = int(input())
s = [list(sorted(input())) for i in range(N)]
s.sort()

ans = []
tmp = 1
for idx,val in enumerate(s):
        if idx == 0:
                continue
        if val == s[idx - 1]:
                tmp += 1
        else:
                ans.append(tmp)
                tmp = 1
else:
        ans.append(tmp)

res = 0
for i in ans:
        res += (i * (i - 1)) // 2
print(res)
### BUGGY CODE ###

H, W, M = map(int, input().split())
h = [0] * M
w = [0] * M

nh = [0] * H  # number of h == i+1
nw = [0] * W  # number of w == i+1

for i in range(M):
    h[i], w[i] = map(int, input().split())
    h[i] -= 1
    w[i] -= 1
    nh[h[i]] += 1
    nw[w[i]] += 1

mnh = max(nh)
mnw = max(nw)

mh = [i for i, nh1 in enumerate(nh) if nh1 == mnh]
mw = [i for i, nw1 in enumerate(nw) if nw1 == mnw]

hw = list(zip(h, w))
for h1 in mh:
    for w1 in mw:
        if (h1, w1) not in hw:
            print(mnh + mnw)
            exit()
print(mnh + mnw - 1)

### FIXED CODE ###

from collections import defaultdict

H, W, M = map(int, input().split())
h = [0] * M
w = [0] * M

nh = [0] * H  # number of h == i+1
nw = [0] * W  # number of w == i+1
dic = defaultdict(bool)

for i in range(M):
    h[i], w[i] = map(int, input().split())
    h[i] -= 1
    w[i] -= 1
    nh[h[i]] += 1
    nw[w[i]] += 1
    dic["{}-{}".format(h[i],w[i])] = True

mnh = max(nh)
mnw = max(nw)

mh = [i for i, nh1 in enumerate(nh) if nh1 == mnh]
mw = [i for i, nw1 in enumerate(nw) if nw1 == mnw]

for h1 in mh:
    for w1 in mw:
        if not dic["{}-{}".format(h1,w1)]:
            print(mnh + mnw)
            exit()
print(mnh + mnw - 1)