Harryxun/stf_run huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    n: usize,
    a: [i32; n],
    }
    let mut upper: i32 = 2 * (10_i32.pow(9));
    let mut lower = 0;
    let mut ans_list = vec![];
    loop {
        let mut half = (upper + lower) / 2;
        if half % 2 == 1 {
            half += (upper + lower) % 2
        }
        let mut tmp = half;
        ans_list.push(tmp);
        for i in 0..n {
            tmp = 2 * (a[i] - tmp / 2);
            if i == n-1 {
                if tmp == ans_list[0] {
                    break
                } else {
                    ans_list.clear();
                    if i % 2 == 0{
                        upper = half
                    } else {
                        lower = half
                    }
                }
                break
            }
            else {
                if tmp < 0 {
                    if i % 2 == 0 {
                        upper = half
                    } else {
                        lower = half
                    }
                    ans_list.clear();
                    break
                } else {
                    ans_list.push(tmp);
                }
            }
        }
        if ans_list.len() == n {
            break
        }
    }
    for i in 0..n {
        print!("{}", ans_list[i]);
        if i < n-1 {
            print!("{}", " ");
        }
    }
}

### FIXED CODE ###

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

S = sum(A)
x1 = S - 2 * sum([A[i] for i in range(len(A)) if i % 2 == 1])
ansList = [x1]
for i in range(1, N):
    tmp = 2 * A[i-1] - ansList[-1]
    ansList.append(tmp)
ansList = [str(a) for a in ansList]
ans = ' '.join(ansList)
print(ans)
A, B = map(int, input().split())
while B != 0:
  A, B = B, A % B
i, j = 0, 1
L = []
for k in range(2, A ** (1/2) + 1):
  z = 0
  for i in range(len(L)):
    if k % L[i] == 0:
      z += 1
      break
  if z == 0:
    L.append(k)
while i <= len(L) and A != 1:
  if A % L[i] == 0:
    j += 1
  i += 1
print(j)

### FIXED CODE ###

A, B = map(int, input().split())
a, b = A, B
while b != 0:
  a, b = b, a % b
prod = 1
s = 1
p = 2
g = a
while a != 1:
  i = 0
  while a % p == 0:
    i += 1
    a //= p
    prod *= p
  if i != 0:
    s += 1
  p += 1
  if p > int(g**(1/2)) and prod != g:
    s += 1
    break
print(s)
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
L = input()
print((L/3)**3)

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
L = INT()
print((L/3)**3)
input = sys.stdin.readline

from collections import Counter

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

#
C=Counter()
for i in range(n):
    C[a[i]] += 1
xsum=0
for key, value in C.items():
    xsum += value*(value-1)//2

#
for k in range(n):
    print( xsum - (C[a[k]] - 1) )

### FIXED CODE ###

from __future__ import print_function

import array
import bisect
import collections
import copy
import fractions
import functools
import heapq
import itertools
import math
import operator
import random
import re
import string
import sys
import time
from collections import Counter, deque
from fractions import Fraction
from functools import reduce
from heapq import heapify, heappop, heappush, heappushpop, heapreplace
from itertools import accumulate
from operator import mul
from queue import PriorityQueue as pq
from queue import Queue

sys.setrecursionlimit(500000)









input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    if r>n:
        return 0
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    n = int(input().strip())
    a = list(map(int, input().strip().split()))
    C=Counter()
    for i in range(n):
        C[a[i]]+=1
    ans_temp=0
    X=[0 for _ in range(n+1)]
    for key, value in C.items():
        X[key] = combinations_count(value, 2)
        ans_temp += X[key]
    for k in range(n):
        print( ans_temp - X[a[k]] + combinations_count(C[a[k]]-1,2) )


if __name__ == '__main__':
    main()
n,a,b = map(int, input().split())

ans=0
for i in range(n):
  num=str(i+1)
  sm=0
  for j in num:
    sm+=j
  if a<=sm<=b:
    ans+=1
print(ans)
    
  

### FIXED CODE ###

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

ans=0
for i in range(n):
  num=str(i+1)
  sm=0
  for j in num:
    sm+=int(j)
  if a<=sm<=b:
    ans+=(i+1)
print(ans)
import copy
import sys
H, W, M= map(int,input().split())
height = [0]*H
width = [0]*W
object = []
for i in range(H):
   wi = [0]*W
   object.append(wi)
for s in sys.stdin.readlines():
    h, w = map(int, s.split())
    height[h-1] += 1
    width[w-1] += 1
    object[h-1][w-1] = 1
h_max = max(height)
w_max = max(width)
cand_w = []
cand_h = []
for i in range(W):
   if width[i] == w_max:
      cand_w.append(i)
for i in range(H):
   if height[i] == h_max:
      cand_h.append(i)
ans = h_max + w_max - 1
p = len(cand_h)*len(cand_w)
if M >= p:
   for i in range(len(cand_h)):
      for j in range(len(cand_w)):
         if object[cand_h[i]][cand_w[j]] == 0:
            ans = h_max + w_max            
else:
   ans += 1
print(ans)

### FIXED CODE ###

import copy
import sys
H, W, M= map(int,input().split())
height = [0]*H
width = [0]*W
object = []
for s in sys.stdin.readlines():
    h, w = map(int, s.split())
    height[h-1] += 1
    width[w-1] += 1
    object.append([h-1, w-1])
h_max = max(height)
w_max = max(width)
cand_w = []
cand_h = []
for i in range(W):
   if width[i] == w_max:
      cand_w.append(i)
for i in range(H):
   if height[i] == h_max:
      cand_h.append(i)
ans = h_max + w_max
c = 0
p = len(cand_h)*len(cand_w)
cand_h = set(cand_h)
cand_w = set(cand_w)
if M >= p:
   for i in range(len(object)):
      if object[i][0] in cand_h and object[i][1] in cand_w:
         c += 1
print(ans - (c == p))
n,q = map(int,input().split())
g = [[] for _ in range(n+1)]
d = [0]*(n+1)
for _ in range(n-1):
    a,b = map(int,input().split())
    g[a].append(b)
for _ in range(q):
    p,x = map(int,input().split())
    d[p] += x
ans = [0]*(n+1)
seen = [False]*(n+1)
def helper(s,cost):
    if not seen[s]:
        seen[s] = True
        ans[s] += cost
        for e in g[s]:
            if not seen[e]:
                helper(e,cost+d[e])
for i in range(1,n+1):
    helper(i,d[i])
res = []
for a in ans[1:]:
    res.append(str(a))

print(' '.join(res))

### FIXED CODE ###

n,q = map(int,input().split())
g = [[] for _ in range(n+1)]
d = [0]*(n+1)
for _ in range(n-1):
    a,b = map(int,input().split())
    g[a].append(b)
    g[b].append(a)
for _ in range(q):
    p,x = map(int,input().split())
    d[p] += x
ans = [0]*(n+1)
seen = [False]*(n+1)
from collections import deque
q = deque([(1,d[1])])
while q:
    s,cost = q.popleft()
    seen[s] = True
    ans[s] += cost
    for e in g[s]:
        if not seen[e]:
            q.append((e,cost+d[e]))
# def helper(s,cost):
#     seen[s] = True
#     ans[s] += cost
#     for e in g[s]:
#         if not seen[e]:
#             helper(e,cost+d[e])
# for i in range(1,n+1):
#     if not seen[i]:
#         helper(i,d[i])
res = []
for a in ans[1:]:
    res.append(str(a))

print(' '.join(res))
import sys

N = int(sys.stdin.readline())
Ns = list(range(1, N + 1))

Ps = list(Ns[i + 1] for i in range(0, N - 1))
Ps.extend([Ns[-1]])
#print(Ns)
#print(Ps)
mod_sum = sum(Ns[i] % Ps[i] for i in range(len(Ns)))
print(mod_sum)

### FIXED CODE ###

import sys

N = int(sys.stdin.readline())
print(int((N - 1) * N // 2))
from sys import stdin

n = int(input())
r = int(input())

if n < 11:
    a = r + 100 * (10-n)
else:
    a = r

print(a)


### FIXED CODE ###

from sys import stdin

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

if n < 10:
    print(r + 100 * (10-n))
else:
    print(r)
#!/usr/bin/env python3
import sys
from operator import mul
from functools import reduce
import math
mod=10**9+7

# def combinations_count(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom

def combinations_count(n, r):
    return (math.factorial(n) // (math.factorial(n - r) * math.factorial(r)))%mod



input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)

n,k=map(int,input().split())
l=n-k
for i in range(1,k+1):
    ans=(combinations_count(l+1,i)*combinations_count(k-1,i-1))%mod
    print(ans)


### FIXED CODE ###

#!/usr/bin/env python3
import sys
from operator import mul
from functools import reduce
import math
mod=10**9+7

# def combinations_count(n, r):
#     r = min(r, n - r)
#     numer = reduce(mul, range(n, n - r, -1), 1)
#     denom = reduce(mul, range(1, r + 1), 1)
#     return numer // denom

def combinations_count(n, r):
    return (math.factorial(n) // (math.factorial(n - r) * math.factorial(r)))%mod



input = lambda: sys.stdin.readline()[:-1]
sys.setrecursionlimit(10**8)

n,k=map(int,input().split())
l=n-k
for i in range(1,k+1):
    if l+1<i or k<i:
        ans=0
    else:
        ans=(combinations_count(l+1,i)*combinations_count(k-1,i-1))%mod
    print(ans)
s = input()
for i in s:
  if s[i] == s[i+1]:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

s = input()
if s[2] == s[3] and s[4] == s[5]:
  print("Yes")
else:
  print("No")
import platform
ver = platform.python_version_tuple()
if int(ver[1]) < 5:
    from fractions import gcd
else:
    from math import gcd
from sys import stdin

def main():
    N, M = map(int, input().split())
    S = input()
    T = input()

    L = lcm(N, M)
    ans = [None] * L
    for i in range(N):
        j = i * (L // N)
        if ans[j] is None or ans[j] == S[i]:
            ans[j] = S[i]
        else:
            print(-1)
            return
    for i in range(M):
        j = i * (L // M)
        if ans[j] is None or ans[j] == T[i]:
            ans[j] = T[i]
        else:
            print(-1)
            return
    print(L)

input = lambda: stdin.readline().rstrip()
lcm = lambda x, y: x * y // gcd(x, y)
main()


### FIXED CODE ###

import platform
ver = platform.python_version_tuple()
if int(ver[1]) < 5:
    from fractions import gcd
else:
    from math import gcd

from sys import stdin
from bisect import bisect

def main():
    N, M = map(int, input().split())
    S = input()
    T = input()

    L = lcm(N, M)
    s = [i * (L // N) + 1 for i in range(N)]
    t = [i * (L // M) + 1 for i in range(M)]
    for i, x in enumerate(s):
        n = bisect(t, x)
        if t[n-1] == x:
            if T[n-1] != S[i]:
                print(-1)
                return
    print(L)

input = lambda: stdin.readline().rstrip()
lcm = lambda x, y: x * y // gcd(x, y)
main()
A, B = map(int, input().split())
 
if B % A == 0：
    print(A+B)
else:
    print(B-A)
    

### FIXED CODE ###

A, B = map(int, input().split())
 
if B % A == 0:
    print(A + B)
else:
    print(B - A)
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A = sorted(A)
    A_M = sorted(A)
    A_M[0] *= -1
    start = 0
    for i in range(1, N-1):
        if A_M[i] < 0:
            A_M[i] *= -1
            start = i
    M = sum(A_M)
    print(M)
    if start == 0:
        for i in range(1, N):
            if i < N-1:
                if i == 1:
                    x = A[0]
                    y = A[1]
                else:
                    x = tmp
                    y = A[i]
            else:
                x = A[-1]
                y = tmp
            tmp = x - y
            print('{} {}'.format(x, y))
    elif start == N - 2:
        for i in range(1, N):
            if i == 1:
                x = A[-1]
                y = A[i-1]
            else:
                x = tmp
                y = A[i-1]
            tmp = x - y
            print('{} {}'.format(x, y))
    else:
        for i in range(1, N):
            if i == 1:
                x = A[start]
                y = A[start+1]
            elif 1 < i < N - 1 - start:
                x = tmp
                y = A[start+i+1]
            elif i == N - 1 - start:
                x = A[-1]
                y = tmp
            else:
                x = tmp
                y = A[i-(N-1-start)-1]
            tmp = x - y
            print('{} {}'.format(x, y))
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split()))
    A = sorted(A)
    A_M = sorted(A)
    A_M[0] *= -1
    start = 0
    if N == 2:
        print(max(A) - min(A))
        print('{} {}'.format(max(A), min(A)))
        return
    for i in range(1, N-1):
        if A_M[i] < 0:
            A_M[i] *= -1
            start = i
    M = sum(A_M)
    print(M)
    if start == 0:
        for i in range(1, N):
            if i < N-1:
                if i == 1:
                    x = A[0]
                    y = A[1]
                else:
                    x = tmp
                    y = A[i]
            else:
                x = A[-1]
                y = tmp
            tmp = x - y
            print('{} {}'.format(x, y))
    elif start == N - 2:
        for i in range(1, N):
            if i == 1:
                x = A[-1]
                y = A[start]
            else:
                x = tmp
                y = A[start-i+1]
            tmp = x - y
            print('{} {}'.format(x, y))
    else:
        for i in range(1, N):
            if i == 1:
                x = A[start]
                y = A[start+1]
            elif 1 < i < N - 1 - start:
                x = tmp
                y = A[start+i]
            elif i == N - 1 - start:
                x = A[-1]
                y = tmp
            else:
                x = tmp
                y = A[start-(i-(N-1-start))]
            tmp = x - y
            print('{} {}'.format(x, y))
    return


if __name__ == '__main__':
    main()
s = list(input())
k = len(s)
i = 0
while i <= len(s) - 2:
    if int(s[i]) + int(s[i+1]) == 1:
        s.pop(i)
        s.pop(i)
        i -=1
    else:
        i +=1
print(k-len(s))

### FIXED CODE ###

s = input()
c0 = s.count('0')
c1 = s.count('1')
print(2 *min(c0, c1))
# abc131_c.py
'''
M を C,D でそれぞれ割り切れるもの
N を CD の最小公倍数で割り切れるもの
とすると
(B - A + 1) - (M - N)
で求められるはず
'''
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
def gcd_list(numbers):
    return reduce(math.gcd, numbers)

def lcm(a,b):
    return (a*b)//gcd(a,b)

A,B,C,D = map(int,input().split())
r = (B - A + 1)
M = math.ceil(r/C) + math.ceil(r/D)
N = math.ceil(r/lcm(C,D))
print(r-M+N)

### FIXED CODE ###


import math
from  fractions import gcd

def lcm(a,b):
    return (a*b)//gcd(a,b)

A,B,C,D = map(int,input().split())
d_cnt = B//D-(A-1)//D
c_cnt = B//C-(A-1)//C
cd = lcm(C,D)
cd_cnt = B//cd-(A-1)//cd
print(B-A+1-(c_cnt+d_cnt-cd_cnt))
a, b = [ int(input()) for i in input().split() ]
ans = "Impossible"
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
  ans = "Possible"
print(ans)

### FIXED CODE ###

a, b = [ int(v) for v in input().split() ]
if a % 3 == 0 or b % 3 == 0 or (a+b) % 3 == 0:
  print("Possible")
else:
  print("Impossible")
lines = map(int, input().split())

# lines = list(map(int, "1 6 3".split()))
lines.sort()

cnt =0
for i in range(len(lines)):
    cnt += lines[2-i]

print(lines[2]-lines[1] + lines[1]-lines[0]  )



### FIXED CODE ###

lines = list(map(int, input().split()))

# lines = list(map(int, "1 6 3".split()))
lines.sort()

cnt =0
for i in range(len(lines)):
    cnt += lines[2-i]

print(lines[2]-lines[1] + lines[1]-lines[0]  )
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	long N,M; cin >> N >> M;
	long K; cin >> K;
	
	vector<long> A(N+1,0);
	for (int i = 1; i <= N; i++) {
		int a; cin >> a;
		A[i] = A[i-1] + a;
	}

	vector<long> B(M+1,0);
	for (int i = 1; i <= M; i++) {
		int b; cin >> b;
		B[i] = B[i-1] + b;
	}

	long ans = 0;
	long best = M;
	for (int i = 1; i <= N; i++) {
		if (A[i] > K) {
			break;	
		}
		
		while (1 < best and B[best] > K - A[i]) {
			best--;		
		}
		ans = max(ans, i+best);

	}
	cout << ans << endl;



	return 0;
}


### FIXED CODE ###

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

a, b = [0], [0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])
      
ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i + j)
print(ans)
def p(n):
    l = list(range(2,n+1))
    p = 2
    i = 0
    p = l[i]
    while True:
        pl = len(l)
        l = list(filter(lambda n: n%p != 0 or n == p,l))
        i += 1
        p = l[i]
        if pl == len(l):
            return pl

from sys import stdin
for i in stdin:
    print(p(int(i)))

### FIXED CODE ###

from math import sqrt,floor
from sys import stdin

def cntPrime(n):
    mx = sqrt(n)
    if n % 2 == 0:
      l = [0, 1] + [1, 0] * (int(n/2) - 1)
    else:
      l = [0, 1] + [1, 0] * (int(n/2) - 1) + [1]
    c = 3
    while c < mx:
        for k in range(c*2, n+1, c):
            l[k-1] = 0
        c = l[(c+1):].index(1) + c +2
        while c % 2 == 0:
            c = l[(c+1):].index(1) + c +2
    return l
t = cntPrime(1000000)
for n in stdin:
    n = int(n)
    print(sum(t[:n]))
r,d,x2000 = map(int,input().split())


for i in range(10):
    if i == 0:
        ans = r*x2000-d
    else:
        ans = r*ans-d
    print(ans)
    
    

### FIXED CODE ###

age,yen = map(int,input().split())
if age>=13:
    print(yen)
elif 6<=age<=12:
    print(yen//2)
else:
    print(0)
a = raw_input()
b = raw_input()

print ''.join([x+y for x,y in zip(a,b)]) + ( a[-1] if len(a) > len(b) else b[-1] if len(b) > len(a) else '' )


### FIXED CODE ###

a,b,c = map(int,raw_input().split())

if a - b == b - c:
  print 'YES'
else:
  print 'NO'
s = input()
t = input()
s = input()
a = [int(c) for c in s]
b = [int(d) for d in t]
ans = 0
for i in range(len(a)):
  if(a[i] != b[i]):
    ans += 1
print(ans)

### FIXED CODE ###

s = input()
t = input()
a = [c for c in s]
b = [d for d in t]
ans = 0
for i in range(len(a)):
  if(a[i] != b[i]):
    ans += 1
print(ans)
import fractions
from collections import defaultdict
A, B = map(int, input().split())
C = fractions.gcd(A, B)
D = set([1])
c = C
for i in range(2, C1):
    while c % i == 0:
        D.add(i)
        c //= i

print(len(D))


### FIXED CODE ###

import fractions
from collections import defaultdict
A, B = map(int, input().split())
C = fractions.gcd(A, B)
c = C

if c == 1:
    print(1)
    exit()


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


print(len(factorization(c))+1)
import numpy as np
h,w,m = map(int,input().split())
bomb = list(tuple(map(lambda x: int(x)-1,input().split())) for i in range(m))
Map= np.zeros((h,w))
for i in bomb:
    Map[i] = 1
print(Map)    
bombx = np.count_nonzero(Map,axis=1)
bomby = np.count_nonzero(Map,axis=0)
maxx = max(bombx)
maxy = max(bomby)
maxx_index = np.where(bombx == maxx)
maxy_index = np.where(bomby == maxy)
print(maxx_index[0],maxy_index[0])
flag = 0
for i in maxx_index[0]:
    for j in maxy_index[0]:
        if Map[i][j] == 0:
            flag = 1
if flag == 0:
    print(maxx+maxy-1)
else:
    print(maxx+maxy)

### FIXED CODE ###

h,w,m = map(int,input().split())
bombX = [0]*h
bombY = [0]*w
bomb = set()
maxX = maxY = 0
for i in range(m):
    i,j = map(lambda x:int(x)-1, input().split())
    bomb.add((i,j))
    bombX[i] += 1
    bombY[j] += 1
    maxX = max(maxX,bombX[i])
    maxY = max(maxY,bombY[j])
maxX_index = list(i for i in range(h) if bombX[i] == maxX)
maxY_index = list(i for i in range(w) if bombY[i] == maxY)
for i in maxX_index:
    for j in maxY_index:
        if (i,j) in bomb: continue
        print(maxX+maxY)
        exit()
print(maxX+maxY-1)