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

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


def main():
    N = int(input().strip())
    ans = 0
    for i in range(1,N+1):
        for j in range(i,N+1,i):
            ans += j
    return ans

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




### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N = int(input().strip())
    ans = 0
    for i in range(1,N+1):
        for j in range(i,N+1,i):
            ans += j
    return ans

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

class Factorial():
    def __init__(self,n,mod):
        self.mod = mod
        self.factorial = [0 for _ in range(n+1)]
        self.inv = [0 for _ in range(n+1)]
        self.factorial[0] = 1
        self.inv[0] = 1
        for i in range(n):
            self.factorial[i+1] = self.factorial[i]*(i+1)%mod
            self.inv[i+1] = self.inv[i]*pow(i+1,mod-2,mod)%mod
    def comb(self,m,k): #組み合わせ 0<=k<=m<=n
        return self.factorial[m]*self.inv[k]*self.inv[m-k]%self.mod
    def fact(self,m): #階乗
        return self.factorial[m]
    def perm(self,m,k): #順列
        if m < k: return 0
        return self.factorial[m]*self.inv[m-k]%self.mod
    def invfact(self,m): #階乗の逆数
        return self.inv[m]

MOD = 1000000007

r1,c1,r2,c2 = map(int,input().split())

f = Factorial(2000010,MOD)

ans = 0

for i in range(r2-r1+1):
    ans += f.comb(r1+c2+i+1,r1+i+1)-f.comb(r1+c1+i,r1+i+1)
    ans %= MOD

print(ans)

### FIXED CODE ###

class Factorial():
    def __init__(self,n,mod):
        self.mod = mod
        self.factorial = [0 for _ in range(n+1)]
        self.inv = [0 for _ in range(n+1)]
        self.factorial[0] = 1
        self.inv[0] = 1
        for i in range(n):
            self.factorial[i+1] = self.factorial[i]*(i+1)%mod
        self.inv[n] = pow(self.factorial[n],mod-2,mod)
        for i in range(n)[::-1]:
            self.inv[i] = self.inv[i+1]*(i+1)%mod


    def comb(self,m,k): #組み合わせ 0<=k<=m<=n
        return self.factorial[m]*self.inv[k]*self.inv[m-k]%self.mod

def solve():

    MOD = 1000000007

    r1,c1,r2,c2 = map(int,input().split())

    f = Factorial(2000010,MOD)

    ans = 0

    for i in range(r2-r1+1):
        ans += f.comb(r1+c2+i+1,r1+i+1)-f.comb(r1+c1+i,r1+i+1)
        ans %= MOD

    print(ans)

solve()
### BUGGY CODE ###

from collections import Counter
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline


def f(c1, c2, c3):
    if dp[c1][c2][c3] is not None:
        return dp[c1][c2][c3]

    res = n
    if c1 != 0:
        res += f(c1 - 1, c2, c3) * c1
    if c2 != 0:
        res += f(c1 + 1, c2 - 1, c3) * c2
    if c3 != 0:
        res += f(c1, c2 + 1, c3 - 1) * c3
    res /= c1 + c2 + c3
    dp[c1][c2][c3] = res
    return res


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

dp = tuple(
    tuple(
        [None] * (n + 1) for _ in range(n + 1)
    ) for _ in range(n + 1))
dp[0][0][0] = 0
# dp[x][y][z]:=1,2,3個の皿がx,y,z残っているときの期待値

c = Counter(a)
c1 = c[1]
c2 = c[2]
c3 = c[3]

print(f(c1, c2, c3))

# dp[now] =
# 1
# + dp[1個の皿を食べた] * p
# + dp[2個の皿を食べた] * p
# + dp[3個の皿を食べた] * p
# + dp[0個の皿を食べた==now] * p


### FIXED CODE ###

def main():
    from collections import Counter

    n = int(input())
    a = tuple(int(x) for x in input().split())

    c = Counter(a)
    c1 = c[1]
    c2 = c[2]
    c3 = c[3]

    x1 = 310 ** 2
    x2 = 310

    dp = [0.0] * (310 ** 3)
    dp[0] = 0.0
    # dp[x * x1 + y * x2 + z]:=1,2,3個の皿がx,y,z残っているときの期待値

    for r3 in range(c3 + 1):
        d3 = c3 - r3
        for r2 in range(c2 + d3 + 1):
            for r1 in range(c1 + d3 + c2 - r2 + 1):
                ind = r1 * x1 + r2 * x2 + r3
                if ind != 0:
                    dp[ind] = (n \
                               + (dp[ind - x1] * r1 if r1 > 0 else 0) \
                               + (dp[ind + x1 - x2] * r2 if r2 > 0 else 0) \
                               + (dp[ind + x2 - 1] * r3 if r3 > 0 else 0)) \
                              / (r1 + r2 + r3)

    print(dp[c1 * x1 + c2 * x2 + c3])


if __name__ == '__main__':
    main()

# dp[now] =
# 1
# + dp[1個の皿を食べた] * p
# + dp[2個の皿を食べた] * p
# + dp[3個の皿を食べた] * p
# + dp[0個の皿を食べた==now] * p

# if mainの追加
# 初期値None->-1.0にした
# checked配列を辞めた
# チェック済みかどうかの判定を-1.0と一致するかの比較にした

# カウントはCounterを使う方が速い
# 1次元にした
# resの加算を複数回に分けると
# 三項演算子より遅くなる
# 再帰関数を辞めた
### BUGGY CODE ###

from bisect import bisect_left
n = int(input())
A=[int(input()) for _ in range(n)]
row = []
for a in A:
    if (not row) or a<=min(row):
        row.append(a)
    else:
        row[len(row) - bisect_left(row[::-1],a)] = a
print(len(row))

### FIXED CODE ###

from bisect import bisect_left
from collections import deque
n = int(input())
A=[int(input()) for _ in range(n)]
q=deque()
for a in A:
    i=bisect_left(q,a)
    if not i:
        q.appendleft(a)
    else:
        q[i-1]=a
print(len(q))
### BUGGY CODE ###

from collections import deque
N = int(input())
A = sorted(list(map(int, input().split())))

ans = 0
  
while True:
  d = A.pop(0)
  if d in A:
    ans -= 1
  
  '''for a in A[::-1]:
    if a % d == 0:
      A.remove(a)'''
  A = list(reversed([ a for a in A[::-1] if a % d != 0]))
  ans += 1
  if A:
    True
  else:
    break
  
print(ans)

### FIXED CODE ###

from numba import njit
import numpy as np

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

@njit
def main(A):
  count = np.zeros(10**6 + 10, np.int32)
  
  for i in range(N):
    a = A[i]
    if count[a] > 1:
      continue
    count[::a] += 1
    
  ans = 0
  for i in range(N):
    ans += count[A[i]] == 1
    
  #print(count[:100])
  return ans
  
print(main(np.array(A, np.int32)))
### BUGGY CODE ###

n, ma, mb = map(int, input().split())
med = [tuple(map(int, input().split())) for _ in range(n)]

INF = 10**8
MAX_M = 400
dp = [[[INF] * (MAX_M + 1) for _ in range(MAX_M + 1)] for _ in range(2)]
dp[0][0][0] = 0
for i, (a, b, c) in enumerate(med):
    i0 = (i + 0) % 2
    i1 = (i + 1) % 2
    for x in range(MAX_M + 1):
        for y in range(MAX_M + 1):
            if x - a >= 0 and y - b >= 0:
                dp[i1][x][y] = min(dp[i0][x][y], dp[i0][x - a][y - b] + c)
            else:
                dp[i1][x][y] = dp[i0][x][y]

ans = INF
for i in range(1, MAX_M + 1):
    if ma * i > MAX_M or mb * i > MAX_M:
        break
    ans = min(ans, dp[n % 2][ma * i][mb * i])
if ans == INF:
    ans = -1

print(ans)


### FIXED CODE ###

n, ma, mb = map(int, input().split())
med = [tuple(map(int, input().split())) for _ in range(n)]

INF = 10**8
MAX_M = 400
dp = [[[INF] * (MAX_M + 1) for _ in range(MAX_M + 1)] for _ in range(2)]
dp[0][0][0] = 0
for i, (a, b, c) in enumerate(med):
    i0 = (i + 0) % 2
    i1 = (i + 1) % 2
    for x in range(MAX_M + 1):
        for y in range(MAX_M + 1):
            if x - a >= 0 and y - b >= 0:
                dp[i1][x][y] = min(dp[i0][x][y], dp[i0][x - a][y - b] + c)
            else:
                dp[i1][x][y] = dp[i0][x][y]

ans = INF
for i in range(1, MAX_M + 1):
    if ma * i > MAX_M or mb * i > MAX_M:
        break
    ans = min(ans, dp[n % 2][ma * i][mb * i])
if ans == INF:
    ans = -1

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

import sys
sys.setrecursionlimit(1000000)
readline = sys.stdin.readline
from collections import deque

def solve_greedy():
    D = int(readline())
    C = list(map(int, readline().split()))
    S = [list(map(int, readline().split())) for i in range(D)]
    N = 26

    lasts = [0] * N

    ans = [None] * D

    for day in range(1, D + 1):
        m, mt = -1e10, 0
        for t in range(N):
            a = S[day - 1][t] + (day - lasts[t]) * C[t]
            if a > m:
                mt = t
                m = a
        
        lasts[mt] = day

        neg = sum((day - lasts[t]) * C[t] for t in range(N))
        pos = S[day - 1][t]

        ans[day - 1] = mt
    
    for a in ans:
        print(a + 1)


def solve_beam():
    D = int(readline())
    C = list(map(int, readline().split()))
    S = [list(map(int, readline().split())) for i in range(D)]
    N = 26

    lasts = [0] * N

    ans = [None] * D

    W, DEPTH = 10, 4

    def rec(day, rem):
        if rem == 0 or day > D:
            return 0, 0
        gains = [(S[day - 1][t] + (day - lasts[t]) * C[t], t) for t in range(N)]
        gains.sort(reverse=True)
        max_gain = -1e10
        max_gain_t = 0
        for i in range(W):
            gain, t = gains[i]
            _t = lasts[t]
            lasts[t] = day
            f_gain, _ = rec(day + 1, rem - 1)
            lasts[t] = _t
            gain += f_gain
            if gain > max_gain:
                max_gain = gain
                max_gain_t = t

        return max_gain, max_gain_t

    #_total = 0
    for day in range(D):
        _, t = rec(day, DEPTH)
        lasts[t] = day
        ans[day - 1] = t
        #_total += _
    
    #print(_total)
    for a in ans:
        print(a + 1)


solve_beam()

### FIXED CODE ###

import sys
readline = sys.stdin.readline

def solve_greedy():
    D = int(readline())
    C = list(map(int, readline().split()))
    S = [list(map(int, readline().split())) for i in range(D)]
    N = 26

    lasts = [0] * N

    ans = [None] * D

    for day in range(1, D + 1):
        m, mt = -1e10, 0
        for t in range(N):
            a = S[day - 1][t] + (day - lasts[t]) * C[t]
            if a > m:
                mt = t
                m = a
        
        lasts[mt] = day

        neg = sum((day - lasts[t]) * C[t] for t in range(N))
        pos = S[day - 1][t]

        ans[day - 1] = mt
    
    for a in ans:
        print(a + 1)



solve_greedy()
### BUGGY CODE ###

n = int(input())
*l, = map(int,input().split())
lone = [0]*60
for i in range(n):
  m = l[i]
  for j in range(59,-1,-1):
    if m >= 2**j:
      m = m -2**j
      lone[j] += 1
ans = 0
for i in range(len(lone)):
  ans += 2**i*lone[i]*(n-lone[i])
print(ans%(10**9+7))


### FIXED CODE ###

#O(nm) = O(60n)で解けるはず・・・！
n = int(input())
l = list(map(int,input().split()))
#2進数の桁の出現数をカウントする。
lone = [0]*60
for i in range(n):
  s = bin(l[i])[2:]
  for j in range(len(s)):
    lone[j] += int(s[-j-1])
ans = 0
for i in range(60):
  ans += (2**i*lone[i]*(n-lone[i]))%(10**9+7)
print(ans%(10**9+7))
### BUGGY CODE ###

#!/usr/bin/env python3
import sys


def solve(A: int, B: int, K: int):
    for i in range(A,B+1):
        if i - A < K or B - i < K:
            print(i)


# 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()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)

if __name__ == '__main__':
    main()


### FIXED CODE ###

#!/usr/bin/env python3
import sys


def solve(A: int, B: int, K: int):
    if (B - A + 1) <= 2*K:
        for i in range(A,B+1):
            print(i)
    else:
        for i in range(A,A+K):
            print(i)
        for i in range(B-K+1,B+1):
            print(i)



# 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()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(A, B, K)

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

def resolve():
    (N, Q) = list(map(int, input().split(" ")))
    S = input()
    LRs = [list(map(int, input().split(" "))) for i in range(Q)]
    mem = [False] * (N-1)
    ptr = 0
    while(True):
        ptr = S.find("AC", ptr)
        if ptr == -1:
            break
        mem[ptr] = True
        ptr = ptr + 1

    for (l, r) in LRs:
        print(sum(mem[l-1:r-1]))

if '__main__' == __name__:
    resolve()

### FIXED CODE ###

def resolve():
    (N, Q) = list(map(int, input().split(" ")))
    S = input()
    LRs = [list(map(int, input().split(" "))) for i in range(Q)]
    mem = [0] * N
    for i in range(N-1):
        if S[i] == "A" and S[i+1] == "C":
            mem[i+1] = mem[i] + 1
        else:
            mem[i+1] = mem[i]

    for (l, r) in LRs:
        print(mem[r-1]-mem[l-1])

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

n, m = map(int, input().split())
count = 0
ans = []
pen = []
penal = 0
p = [0]*m
x = [0]*m
for i in range(m):
    p[i], x[i] = map(str, input().split())
    if x[i] == "AC":
        ans.append(p[i])
    elif x[i] == "WA":
        for j in range(len(ans)):
            if p[i] == ans[j]:
                penal -= 1
                break
        penal += 1
        pen.append((p[i], x[i]))

ans = list(set(ans))

for i in range(len(pen)):
    if pen[i][0] not in ans:
        penal -= 1


print("{}".format(len(ans)) + " {}".format(penal))


### FIXED CODE ###

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

problem = [0] * n
count = [0] * n

penal = 0

for i in range(m):
    p, x = map(str, input().split())
    p = int(p) - 1
    if x == "AC":
        if problem[p] == 0:
            problem[p] = 1
    elif x == "WA":
        if problem[p] == 0:
            count[p] += 1

for i in range(n):
    if problem[i] == 0:
        count[i] = 0

print("{}".format(sum(problem)) + " {}".format(sum(count)))
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
ts, ds = [], []
for _ in range(q):
    t, d = input().split()
    ts.append(t)
    ds.append(d)

def reachable(n, dest):
    for t, d in zip(ts, ds):
        if s[n] == t:
            n = n - 1 if d == 'L' else n + 1
        if n == dest:
            return True
        elif not 0 <= n <= len(s) - 1:
            return False
    return False


l, r = -1, n
while r - l > 1:
    m = l + (r - l) // 2
    if reachable(m, -1):
        l = m
    else:
        r = m
ldel = l + 1

l, r = -1, n
while r - l > 1:
    m = l + (r - l) // 2
    if reachable(m, n):
        r = m
    else:
        l = m
rdel = n - r

print(max(n - (ldel + rdel), 0))


### FIXED CODE ###

n, q = map(int, input().split())
s = input()
ts, ds = [], []
for _ in range(q):
    t, d = input().split()
    ts.append(t)
    ds.append(d)

def reachable(n, dest):
    for t, d in zip(ts, ds):
        if s[n] == t:
            n = n - 1 if d == 'L' else n + 1
        if n == dest:
            return True
        elif not 0 <= n <= len(s) - 1:
            return False
    return False


l, r = -1, n
while r - l > 1:
    m = l + (r - l) // 2
    if reachable(m, -1):
        l = m
    else:
        r = m
ldel = l + 1

l, r = -1, n
while r - l > 1:
    m = l + (r - l) // 2
    if reachable(m, n):
        r = m
    else:
        l = m
rdel = n - r

print(max(n - (ldel + rdel), 0))
### BUGGY CODE ###

N = int(input())
L = list(map(int, input().split()))
total = 0

for i in range(N-2):
    for j in range(i+1, N-1):
        a = max(L[i], L[j])
        b = min(L[i], L[j])
        for k in range(j+1, N):
            if a - b < L[k] < a + b:
                total += 1

print(total)


### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
total = 0

for i in range(N-2):
    a = L[i]
    for j in range(i+1, N-1):
        b = L[j]
        # j以降の項で、初めてL[k] < a-bとなるkを二分探索する
        if L[-1] > a - b:  # 一番最後の項でもOKな場合(j+1以降全部OK)
            total += N - j - 1
        elif L[j+1] <= a - b:  # 一番最初の項からNGな場合
            continue
        else:
            head = j+1  # head はL[head] > a - bを満たす(OK側)
            tail = N-1  # tail はL[tail] <= a - bを満たす(NG側)
            while head+1 != tail:
                if L[(head + tail)//2] > a - b:  # 中間地点はOK側
                    head = (head + tail) // 2
                else:  # 中間地点はNG側
                    tail = (head + tail) // 2
            total += head - j

print(total)
### BUGGY CODE ###

n, k = map(int, input().split())
l = [_ for _ in range(n + 1)]

x = 0
for i in range(k, n+2):
    x += sum(l[-1:-i-1:-1]) - sum(l[0:i]) + 1

print(x % (10**9+7))


### FIXED CODE ###

n, k = map(int, input().split())
l = [_ for _ in range(n + 1)]

tmp_min = sum(l[0:k])
tmp_max = sum(l[-1:-k-1:-1])
x = tmp_max - tmp_min + 1

for i in range(n-k+1):
    tmp_min += l[k+i]
    tmp_max += l[-k-i-1]
    x += tmp_max - tmp_min + 1

print(x % (10**9+7))
### BUGGY CODE ###

H,W = map(int, input().strip().split())
Ch, Cw = map(int, input().strip().split())
Dh, Dw = map(int, input().strip().split())
Ch += 1
Cw += 1
Dh += 1
Dw += 1

moves=[]
for i in range(H+4):
    moves.append([1000000]*(W+4))

for i in range(2,H+2):
    s = input().strip()
    for j in range(W):
        if s[j] == '#':
            moves[i][j+2] = -1

for i in range(H+4):
    for j in range(W+4):
        if i<=1 or i>=H+2 or j<=1 or j>=W+2:
            moves[i][j]=-1


moves[Ch][Cw]=0
sources_0 = [[-1,0],[1,0],[0,-1],[0,1]]
sources_1 = [[-2,-2],[-1,-2],[0,-2],[1,-2],[2,-2]]
sources_1 += [[-2,-1],[-1,-1],[0,-1],[1,-1],[2,-1]]
sources_1 += [[-2,0],[-1,0],[1,0],[2,0]]
sources_1 += [[-2,1],[-1,1],[0,1],[1,1],[2,1]]
sources_1 += [[-2,2],[-1,2],[0,2],[1,2],[2,2]]

n = 0
while (n <= H*W):
    n += 1
    for i in range(2,H+2):
        for j in range(2,W+2):
            if moves[i][j] <= 0:
                continue
            for src in sources_0:
                src_move = moves[i+src[0]][j+src[1]]
                if src_move >= 0 and src_move < moves[i][j]:
                    moves[i][j] = src_move
            for src in sources_1:
                src_move = moves[i+src[0]][j+src[1]]
                if src_move >= 0 and src_move + 1 < moves[i][j]:
                    moves[i][j] = src_move + 1

if moves[Dh][Dw] == 1000000:
    print(-1)
else:
    print(moves[Dh][Dw])

### FIXED CODE ###

from collections import deque

H,W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
Ch -= 1
Cw -= 1
Dh -= 1
Dw -= 1

squares = []
for i in range(H):
    squares.append([None]*(W))

for i in range(H):
    s = input()
    for j in range(W):
        if s[j] == '#':
            squares[i][j] = -1  # Wall

squares[Ch][Cw]=0

d1 = deque()
d2 = deque()
d1.append([Ch, Cw])

warps = 0

def visit(i1, j1, i2, j2, with_warp = False):  # (i1,j1) to (i2,j2)
    if i2 < 0 or i2 >= H or j2 < 0 or j2 >= W:
        return
    sq2 = squares[i2][j2]
    if sq2 == None:
        if with_warp:
            squares[i2][j2] = warps + 1  # sq2 = warps + 1 <- doesn't work
        else:
            squares[i2][j2] = warps  # sq2 = warps <- doesn't work
        d1.append([i2, j2])
        if i2 == Dh and j2 == Dw:
            print(squares[i2][j2])
            exit()

while (len(d1)>0):
    while (len(d1)>0):
        src = d1.popleft()
        visit(src[0], src[1], src[0] - 1, src[1])
        visit(src[0], src[1], src[0] + 1, src[1])
        visit(src[0], src[1], src[0], src[1] - 1)
        visit(src[0], src[1], src[0], src[1] + 1)
        d2.append(src)

    while (len(d2)>0):
        src = d2.popleft()
        for i in range(-2,3):
            for j in range(-2,3):
                visit(src[0], src[1], src[0]+i, src[1]+j, True)

    warps += 1

print(-1)
### BUGGY CODE ###

from bisect import bisect_right

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(key=lambda x: x[1], reverse=True)

res = 0
for b, c in bc:
    count = bisect_right(a, c, hi=min(b, len(a)))
    res += count * c
    if count > 0:
        a = a[count:]

print(res + sum(a))


### FIXED CODE ###

from bisect import bisect_right

n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
bc = [list(map(int, input().split())) for _ in range(m)]
bc.sort(key=lambda x: x[1], reverse=True)

res = 0
fin = 0
for b, c in bc:
    count = bisect_right(a, c, lo=fin, hi=min(fin+b, len(a))) - fin
    fin += count
    res += count * c
for i in range(fin, len(a)):
    res += a[i]

print(res)
### BUGGY CODE ###

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

### FIXED CODE ###

import numpy as np
n=int(input())
a=list(map(int,input().split()))
  
x = np.argsort(a)
for i in range(n):
  print(x[i]+1)
### BUGGY CODE ###

N=int(input())
A=list(map(int,input().split()))
ans=0
for i in range(len(A)):
  flag=1
  for j in range(0,i):
    if A[i]>A[j]:
      flag=0
      break
  if flag==1:
    ans+=1
print(ans)
    
      

### FIXED CODE ###

N=int(input())
A=list(map(int,input().split()))
tmp=[]
a=10**9
for i in A:
  if a>i:
    a=i
  tmp.append(a)
ans=0
for i in range(len(A)):
  if A[i]<=tmp[i]:
    ans+=1
print(ans)
### BUGGY CODE ###

H,W,M=map(int, input().split())
nrow=[0]*H
ncol=[0]*W
xycoord=[]

for _ in range(M):
	h,w=map(int, input().split())
	nrow[h-1]+=1
	ncol[w-1]+=1
	xycoord+=[[w-1,h-1]]

#ncol=collections.Counter(xcoord)
#nrow=collections.Counter(ycoord)

row_cand=[i for i, x in enumerate(nrow) if x == max(nrow)]
col_cand=[i for i, x in enumerate(ncol) if x == max(ncol)]


flag=0
for i in xycoord:
	if (i[0] in col_cand) and (i[1] in row_cand):
		flag+=1

if flag<(len(col_cand)*len(row_cand)):
	print(max(nrow)+max(ncol))
else:
	print(max(nrow)+max(ncol)-1)



# 2darray [[0] * 4 for i in range(3)]
# import itertools

### FIXED CODE ###

H,W,M=map(int, input().split())
nrow=[0]*H
ncol=[0]*W
xycoord=[]

for _ in range(M):
	h,w=map(int, input().split())
	nrow[h-1]+=1
	ncol[w-1]+=1
	xycoord+=[[w-1,h-1]]

#ncol=collections.Counter(xcoord)
#nrow=collections.Counter(ycoord)

a=max(nrow)
b=max(ncol)
row_cand=set([i for i, x in enumerate(nrow) if x == a])
col_cand=set([i for i, x in enumerate(ncol) if x == b])


flag=0
for i in xycoord:
	if (i[0] in col_cand) and (i[1] in row_cand):
		flag+=1

if flag<(len(col_cand)*len(row_cand)):
	print(max(nrow)+max(ncol))
else:
	print(max(nrow)+max(ncol)-1)



# 2darray [[0] * 4 for i in range(3)]
# import itertools
### BUGGY CODE ###

L,R = map(int,input().split())
ans = 2019
for i in range(L,R):
    for j in range(i+1,R+1):
        ans = min(ans,(i*j)%2019)
        if ans == 0:
            break

print(ans)


### FIXED CODE ###

L,R = map(int,input().split())
ans = 2019
for i in range(L,R):
    for j in range(i+1,R+1):
        ans = min(ans,(i*j)%2019)
        if ans == 0:
            break
    if ans == 0:
        break

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

L, R = map(int, input().split())

M = []
for i in range(L, R+1):
  for j in range(i+1, R+1):
    M.append((i % 2019) * (j % 2019) % 2019)
if len(M) == 0:
  print(L)
else:
  print (min(M))

### FIXED CODE ###

L, R = map(int, input().split())
if R-L >= 2019:
  print (0)
else:
  print (min([((i % 2019) * (j % 2019)) % 2019 for i in range(L,R) for j in range(i+1,R+1)]))