jiahuimbzuai/CoQuIR huggingface dataset:
//  [java]

import java.util.Scanner;
import java.util.stream.Stream;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String[] astr = str.split(""); //状況に合わせて
        Boolean flag = true;
        int[] in_data = Stream.of(astr).mapToInt(x -> {
            try {
                return Integer.parseInt(x);
            } catch (Exception e) {
                e.printStackTrace();
            }
            return 0;
        }).toArray();
        sc.close();

        int tmp = in_data[0] * in_data[0] * in_data[0];
        System.out.println(tmp);
    }
}
//  [cpp]
#include<cstdio>
using namespace std;
int main()
{
	int n,i,j,k,cnt;
	scanf("%d",&n);
	cnt=0;
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			for(k=1;k<=n;k++){
				cnt++;
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
}
//  [cpp]
#include <stdio.h>

int main() {
  int N;
  scanf("%d", &N);
  printf("%d\n", N * N * N);
  return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,rslt;
    scanf("%d",&n);
    rslt=pow(n,3);
    printf("%d\n",rslt);
    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
int main(){
    ll n,ans=0;cin>>n;
    vector<ll> vec(10000000);
    for(ll i=0;i<1000;i++){
        for(ll j=0;j<10000;j++){
            for(int k=0;k<199;k++){
                vec.at(i+j+k)++;
            }
        }
    }
    cout<<n*n*n<<endl;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n) for(ll i=0;i<(n);i++)
int main(){
    ll n,ans=0;cin>>n;
    vector<ll> vec(10000000);
    for(ll i=0;i<1000;i++){
        for(ll j=0;j<10000;j++){
            for(int k=0;k<50;k++){
                vec.at(i+j+k)++;
            }
        }
    }
    cout<<n*n*n<<endl;
}
//  [cpp]
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
int N;
   cin >> N;
   N = N*N*N;
   cout << N << endl;
}
//  [c]
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  printf("%d\n",n*n*n);
  return 0;
}
//  [c]
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        printf("%d\n",n*n*n);
    }
    return 0;
}
//  [c]
#include <stdio.h>

int main(void){
  int n;
  scanf("%d", &n);
  printf("%d", n*n*n);
  return 0;
}
//  [c]
#include<stdio.h>
#include<string.h>

#define MAX_N 9

int main()
{
    int n, a;

    scanf("%d", &n);

    a = n*n*n;

    printf("%d", a);

    return 0;
}
//  [c]
main(){system("awk '$0^=3'");}
//  [c]
#include<stdio.h>
int main(){
  int N;
  scanf("%d",&N);
  
  printf("%d",N*N*N);
  
  return 0;
}
//  [javascript]
main = input => {
  process.stdout.write(Math.pow(Number(input),3));
}

main(require('fs').readFileSync('/dev/stdin','utf8'));
//  [javascript]
function Main(input) {
    "use strict"
    const temp = input.split("\n");
    const n = parseInt(temp.shift());
    console.log(n * n * n)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
"use strict";
main(require("fs").readFileSync("/dev/stdin", "UTF-8"));

function main(input) {
  input = parseInt(input.split("\n").shift(), 10);
  console.log(Math.pow(input, 3));
}
//  [javascript]

function Main(input) {
    input = input.split("\n")
    input = input[0].split('')    
    
    var count = 0

    for(var i=1;i<=input;i++){
        for(var j=1;j<=input;j++){
            for(var k=1;k<=input;k++){
                count++
            }
        }
    }
    console.log("%d",count)

}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）

Main(require("fs").readFileSync("/dev/stdin", "utf8"))
//  [javascript]
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入
  var input = Number(input)
	console.log(Math.pow(input, 3));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n=o.a();
  return n*n*n;
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var (
	scanner = bufio.NewScanner(os.Stdin)
)

func readInt() int {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	return n
}

func main() {
	n := readInt()
	fmt.Println(n * n * n)
}
//  [go]
package main

import(
    "fmt"
    "math"
)

func main(){
    var N float64
    fmt.Scan(&N)
    answer := math.Pow(N, 3)
    fmt.Println(int(answer))
}
//  [go]
package main
 
import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
	"math"
)
 
func run() {
	n := nextFloat()
	
	Println(math.Pow(n, 3))
}
 
// --- template ---
// Thanks https://gist.github.com/halllllll/853ab587fd82ee3ffe6f7fb7fb499695
 
var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)
 
// Caution: You will get unexpected result if a single token is larger than this size.
const BufferSize = 64 * 1024 * 1024
 
func Print(a ...interface{}) (n int, err error) {
	return fmt.Fprint(out, a...)
}
 
func Printf(format string, a ...interface{}) (n int, err error) {
	return fmt.Fprintf(out, format, a...)
}
 
func Println(a ...interface{}) (n int, err error) {
	return fmt.Fprintln(out, a...)
}
 
func next() string {
	sc.Scan()
	return sc.Text()
}
 
func nextInt() int {
	a, err := strconv.Atoi(next())
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func nextFloat() float64 {
	a, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		log.Fatal(err)
	}
	return a
}
 
func main() {
	sc.Buffer(make([]byte, 0, BufferSize), BufferSize)
	sc.Split(bufio.ScanWords)
	run()
	out.Flush()
}
//  [go]
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Println(math.Pow(float64(n), 3.0))
}
//  [ruby]
N = gets.to_i
puts N**3
//  [ruby]
n = gets.to_i

puts n**3
//  [ruby]
n = gets.to_i

count = 0

n.times do    # オブジェクト.times do |変数|
  n.times do  # 対象のオブジェクトが持つ数値 -1 を順に代入
    n.times do
      count += 1
    end
  end
end

puts count
//  [ruby]
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N = get_int

puts N ** 3
//  [ruby]
puts gets.to_i ** 3
//  [ruby]
s = gets().chomp.to_i

puts s**3
//  [rust]
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
    }
   
    
    println!("{}", n*n*n);
}
//  [rust]
fn main() {
    let n = read::<usize>();
    println!("{}", n * n * n)
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}
//  [rust]
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    let N = buf.trim().parse::<u32>().unwrap();
    let ans = N.pow(3);
    println!("{}", ans);
}
//  [rust]
use text_io::*;
use std::collections::*;
use std::process::exit;

fn main() {
    let mut n:usize = read!();
    println!("{}",n*n*n);
}
//  [swift]
let a = Int(readLine()!)!
var o = 0
var i = 0

if (a == 1) {
    o = 1
} else {
    o = a
    for i in 0..<2 {
    o = o * a
}
}

print(o)
//  [swift]
let N = Int(readLine()!)!
 
print(N * N * N)
//  [swift]
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let n = Int(readLine()!)!
    
    print(n * n * n)
}

main()
//  [swift]
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
let num = readInts()
print(num[0]*num[0]*num[0])
//  [swift]
let a=Int(readLine()!)!
var o = 0
var i = 0

if(  a == 1 ) {
  o = 1
} else {
  o = a
  for i in 0..<2 {
      o =  o * a
  }
}

print( o )
//  [typescript]
function main(input) {
    const n: number = parseInt(input.split('\n')[0], 10);
    console.log(n * n * n);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
import * as fs from 'fs';

//in
//
//out
//
const main = (inp:string) => {
    const n :number = parseInt(inp);
    console.log(n**3);
};

main(fs.readFileSync('/dev/stdin','utf8').trim());
//  [typescript]
function Main(input) {
  let n = parseInput(input)[0][0];
  console.log(n ** 3);
}

function parseInput(input) {
  const lines = input.trim().split('\n');
  return lines.map(line => line.split(' '));
}

Main(require('fs').readFileSync("/dev/stdin", "utf8"));
//  [typescript]
"use strict";

const main = arg => {
  const input = arg.trim().split("\n");
  const N = parseInt(input[0].split(" ")[0]);
  console.log(N * N * N);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [typescript]
const main = lines => {
  console.log(solve(lines));
};

const solve = (lines: string[]): string => {
  const [N] = parseLines(lines);

  return ((+N) ** 3).toString();
};

const parseLines = (lines: string[]) => {
  const obj = lines;
  debug(obj);
  return obj;
};

const debug = (message?: any, ...optionalParams: any[]) => {
  if (!!process.env.LOCAL_DEBUG) console.log(message, ...optionalParams);
};

if (!process.env.LOCAL_DEBUG) {
  const { stdin: input, stdout: output } = process;
  input.resume();
  input.setEncoding('utf8');
  const lines = [];
  require('readline')
    .createInterface({ input, output })
    .on('line', line => lines.push(line))
    .on('close', () => main(lines));
}

export default solve;
//  [typescript]
// general helpers
const debug = (message?: any, ...optionalParams: any[]) => {
  if (process.env.LOCAL_DEBUG === '1') console.log(message, ...optionalParams)
}

// helpers
const parseLines = (
  lines: string[]
): { N: number } => {
  const N = +lines[0]
  const obj = { N }
  debug(obj)
  return obj
}
// solver
export const solve = (lines: string[]): string => {
  const { N } = parseLines(lines)
  return `${N ** 3}`
}

// main
const main = (lines: string[]) => {
  console.log(solve(lines))
}

// exec main function for submit
if (process.env.LOCAL_DEBUG !== '1') {
  const { stdin: input, stdout: output } = process
  input.resume()
  input.setEncoding('utf8')
  const lines: string[] = []
  require('readline')
    .createInterface({ input, output })
    .on('line', (line: string) => lines.push(line))
    .on('close', () => main(lines))
}
//  [python]
import random
import time

t0 = time.time()

H, W, M = map(int, input().split())
count_h = [0] * H
count_w = [0] * W
bomb = set()
for _ in range(M):
    h, w = map(int, input().split())
    bomb.add((h-1, w-1))
    count_h[h-1] += 1
    count_w[w-1] += 1

max_count_h = max(count_h)
max_count_w = max(count_w)

hs = [h for h in range(H) if count_h[h] == max_count_h]
ws = [w for w in range(W) if count_w[w] == max_count_w]

# H, W, M, bomb, count_h, count_w, hs, ws

ans = max_count_h + max_count_w

# t0 = time.time()
flag = False
while time.time() - t0 < 2.8:
    h = random.choice(hs)
    w = random.choice(ws)
    if (h, w) not in bomb:
#         print(h, w)
        flag = True
        break
if flag:
    print(ans)
else:
    print(ans - 1)
//  [python]
h,w,m=map(int,input().split())
x=[]
y=[]
from collections import deque
for i in range(m):
    h1,w1=map(int,input().split())
    x.append([h1,w1])
    y.append([w1,h1])
x.sort()
y.sort()
a=0
b=0
s=0
t=0
ans1=0
ans2=0
for i in range(m):
    if a==x[i][0]:
        s+=1
    else:
        a=x[i][0]        
        ans1=max(ans1,s)
        s=1
ans1=max(ans1,s)
for i in range(m):
    if b==y[i][0]:
        t+=1
    else:
        b=y[i][0]
        ans2=max(ans2,t)
        t=1
ans2=max(ans2,t)
a=0
b=0
s=0
t=0
d=deque()
e=deque()
for i in range(m):
    if a==x[i][0]:
        s+=1
    else:
        if s==ans1:
            d.append(a)
        a=x[i][0]
        s=1
if s==ans1:
    d.append(a)
for i in range(m):
    if b==y[i][0]:
        t+=1
    else:
        if t==ans2:
            e.append(b)
        b=y[i][0]
        t=1
if t==ans2:
    e.append(b)
ab=len(d)*len(e)
n=[]
for i in range(m):
    if x[i][0]==d[0]:
        n.append(x[i][1])
    elif x[i][0]>d[0]:
        d.popleft()
        if len(d)==0:
            break
        if x[i][0]==d[0]:
            n.append(x[i][1])
n.sort()
p=0
for i in range(len(n)):
    if n[i]==e[0]:
        p+=1
    elif n[i]>e[0]:
        e.popleft()
        if len(e)==0:
            break
        if n[i]==e[0]:
            p+=1
if p==ab:
    print(ans1+ans2-1)
else:
    print(ans1+ans2)
//  [python]
h,w,m = map(int, input().split())

lh = []
lw = []

for i in range(m):
  h1,w1 = map(int, input().split())
  lh.append(h1)
  lw.append(w1)

if h == 1 or w == 1:
  print(m)
else:
  from collections import Counter as co
  ch=co(lh).most_common()
  cw=co(lw).most_common()
  
  ans = 0
  tmp = ch[0][0]
  lh_c = [i for i, x in enumerate(lh) if x == tmp]
  lw_tmp = lw[:]
  for j in sorted(lh_c, reverse=True):
    lw_tmp.pop(j)
  if len(lw_tmp) == 0:
    print(ch[0][1])
  else:
    cw_tmp = co(lw_tmp).most_common()
    ans = ch[0][1]+cw_tmp[0][1]
    
    tmp = cw[0][0]
    lw_c = [i for i, x in enumerate(lw) if x == tmp]
    lh_tmp = lh[:]
    for j in sorted(lw_c, reverse=True):
      lh_tmp.pop(j)
    if len(lh_tmp) == 0:
      print(cw[0][1])
    else:
      ch_tmp = co(lh_tmp).most_common()
      ans = max(ans, cw[0][1]+ch_tmp[0][1])
      print(ans)
//  [java]
//package beginner176;

import java.util.*;

public class Main {

    public static class Node{
        int r;
        int c;

        public Node(int pr, int pc){
            r = pr;
            c = pc;
        }
    }

    public static class Record{
        int index;
        int cnt;
        public Record(int i, int c){
            index = i;
            cnt = c;
        }
    }

    public static void main(String[] args){
        int H, W;

        Scanner in = new Scanner(System.in);

        H = in.nextInt();
        W = in.nextInt();
        int M = in.nextInt();
        int row[] = new int[H + 1];
        int col[] = new int[W + 1];
        int target[][] = new int[M][2];
        TreeMap<Node, Integer> treeMap = new TreeMap<Node, Integer>(new Comparator<Node>() {
            @Override
            public int compare(Node o1, Node o2) {
                if(o1.r != o2.r){
                    return o1.r - o2.r;
                }
                return o1.c - o2.c;
            }
        });
        Map<Integer, List<Integer>> edgeRow = new HashMap<>();

        for(int i = 0; i < M; i++){
            int r = in.nextInt();
            int c = in.nextInt();
            target[i][0] = r;
            target[i][1] = c;
            treeMap.put(new Node(r, c), 0);
            row[r]++;
            col[c]++;
            add(r, c, edgeRow);

        }

        Comparator<Record> cmp = new Comparator<Record>() {
            @Override
            public int compare(Record o1, Record o2) {
                return o2.cnt - o1.cnt;
            }
        };

        List<Record> colList = new ArrayList<Record>();
        for(int i = 1; i <= W; i++){
            colList.add(new Record(i, col[i]));
        }
        colList.sort(cmp);

        int result = 0;

        for(int i = 1; i <= H; i++){
            int r = row[i];
            result = Math.max(result, r);
            if(edgeRow.containsKey(i)){
                List<Integer> list = edgeRow.get(i);

                for(int x : list){
                    result = Math.max(result, r - 1 + col[x]);
                }
            }
            for(int j = 0; j < colList.size(); j++){
                Record record = colList.get(j);
                if(treeMap.containsKey(new Node(i, record.index))){
                    continue;
                }
                result = Math.max(result, r + record.cnt);
                break;
            }
        }
        System.out.println(result);

    }

    public static void add(int i, int j, Map<Integer, List<Integer>> map){
        if(map.containsKey(i)){
            map.get(i).add(j);
        }else{
            List<Integer> list = new ArrayList<>();
            list.add(j);
            map.put(i, list);
        }
    }
}
//  [java]
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int H = scan.nextInt();
        int W = scan.nextInt();
        int M = scan.nextInt();
        int[] h = new int[M];
        int[] w = new int[M];
        HashMap<Integer, List<Integer>> map_h = new HashMap<>();
        HashMap<Integer, List<Integer>> map_w = new HashMap<>();
        HashSet<Long> cache = new HashSet<>();
        for (int i = 0; i < M; i++) {
            h[i] = scan.nextInt();
            w[i] = scan.nextInt();
            cache.add((long) h[i]*1000000 + (long) w[i]);
            if (!map_h.containsKey(h[i])) {
                map_h.put(h[i], new ArrayList<>());
            }
            if (!map_w.containsKey(w[i])) {
                map_w.put(w[i], new ArrayList<>());
            }
            map_h.get(h[i]).add(i);
            map_w.get(w[i]).add(i);
        }
        List<Integer> vl = new ArrayList<>();
        List<Integer> hl = new ArrayList<>();
        HashMap<Integer, HashSet<Integer>> list_vertical = new HashMap<>();
        for (int y : map_h.keySet()) {
            int count = map_h.get(y).size();
            if (!list_vertical.containsKey(count)) {
                list_vertical.put(count, new HashSet<>());
                vl.add(count);
            }
            list_vertical.get(count).add(y);
        }
        HashMap<Integer, HashSet<Integer>> list_horizontal = new HashMap<>();
        for (int x : map_w.keySet()) {
            int count = map_w.get(x).size();
            if (!list_horizontal.containsKey(count)) {
                list_horizontal.put(count, new HashSet<>());
                hl.add(count);
            }
            list_horizontal.get(count).add(x);
        }
        vl.sort(Comparator.reverseOrder());
        hl.sort(Comparator.reverseOrder());
        long ans = vl.get(0) + hl.get(0)-1;
        for (int y : list_vertical.get(vl.get(0))) {
            for (int x : list_horizontal.get(hl.get(0))) {
                long index = (long) y * 1000000 + (long) x;
                if (!cache.contains(index)) {
                    System.out.println(ans + 1);
                    return;
                }
            }
        }
        System.out.println(ans);
    }
}
//  [cpp]
#include<cstdio>
#include<bits/stdc++.h>
using namespace std;
int const nax = 3e5 + 10;

int n, m, k;

int ct_n[nax];
int ct_m[nax];

vector <pair <int, int>> a;
vector <int> b[nax];

int main() {
    clock_t start = clock();
    scanf("%d %d %d", &n, &m, &k);

    while ((clock() - start) / double(CLOCKS_PER_SEC) < 2.6);

    for (int i = 1 ; i <= k ; ++ i) {
        int h, w;
        scanf("%d %d", &h, &w);
        ++ ct_n[h];
        ++ ct_m[w];
        a.emplace_back(h, w);
        b[h].emplace_back(w);
    }

    int ans = 0;

    multiset <int> naive;

    for (auto [x, y] : a) {
        ans = max(ans, ct_n[x] + ct_m[y] - 1);
    }

    for (int i = 1 ; i <= m ; ++ i) {
        naive.insert(ct_m[i]);
    }

    for (int i = 1 ; i <= n ; ++ i) {
        for (int j : b[i]) {
            naive.erase(naive.find(ct_m[j]));
        }

        int res = naive.empty() ? 0 : *naive.rbegin();
        ans = max(ans, ct_n[i] + res);
        for (int j : b[i])
            naive.insert(ct_m[j]);
    }
    printf("%d\n", ans);
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    int H, W, M; cin >> H >> W >> M;
    unordered_map<int, int> x_counter;
    unordered_map<int, int> y_counter;
    unordered_map<int, unordered_set<int>> bombs;
    auto has = [&](int x, int y){
        if (bombs.count(x) == 0) return false;
        return static_cast<bool>(bombs.at(x).count(y));
    };
    for (int i = 0; i < M; ++i) {
        int x, y; cin >> x >> y; --x; --y;
        bombs[x].insert(y);
        x_counter[x]++;
        y_counter[y]++;
    }
    vector<pair<int, int>> vx;
    vector<pair<int, int>> vy;
    for (auto [x, c]: x_counter) {
        vx.emplace_back(c, x);
    }
    for (auto [y, c]: y_counter) {
        vy.emplace_back(c, y);
    }
    sort(vx.begin(), vx.end());
    sort(vy.begin(), vy.end());
    reverse(vx.begin(), vx.end());
    reverse(vy.begin(), vy.end());
    int ans = 0;
    for (int i = 0; i < min(vx.size(), (unsigned long)100); ++i) {
        for (int j = 0; j < vy.size(); ++j) {
            int x = vx[i].second;
            int x_count = vx[i].first;
            int y = vy[j].second;
            int y_count = vy[j].first;
            if (has(x, y)) {
                // cout << "*";
                // cout << x + 1 << " " << y + 1 << " " << x_count << " " << y_count << " " << x_count + y_count - 1 << endl;
                ans = max(ans, x_count + y_count - 1);
            } else {
                // cout << " ";
                // cout << x + 1 << " " << y + 1 << " " << x_count << " " << y_count << " " << x_count + y_count << endl;
                ans = max(ans, x_count + y_count);
            }
        }
    }
    for (int i = 0; i < vx.size(); ++i) {
        for (int j = 0; j < min(vy.size(), (unsigned long)100); ++j) {
            int x = vx[i].second;
            int x_count = vx[i].first;
            int y = vy[j].second;
            int y_count = vy[j].first;
            if (has(x, y)) {
                // cout << "*";
                // cout << x + 1 << " " << y + 1 << " " << x_count << " " << y_count << " " << x_count + y_count - 1 << endl;
                ans = max(ans, x_count + y_count - 1);
            } else {
                // cout << " ";
                // cout << x + 1 << " " << y + 1 << " " << x_count << " " << y_count << " " << x_count + y_count << endl;
                ans = max(ans, x_count + y_count);
            }
        }
    }

    cout << ans << endl;
    return 0;
}
//  [cpp]
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
#define mp(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

const int N = 3e5 + 5;
vi gr[N], gc[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h, w, m;
    cin >> h >> w >> m;
    map<int, int> cntr, cntc;
    map<pii, bool> ada;
    for (int i = 0; i < m; i++) {
        int th, tw;
        cin >> th >> tw;
        gr[th].pb(tw);
        gc[tw].pb(th);
        cntr[th]++;
        cntc[tw]++;
    }
    set<pii> sr, sc;
    for (auto it: cntr) {
        sr.insert({it.se, it.fi});
    }
    for (auto it: cntc) {
        sc.insert({it.se, it.fi});
    }
    int ans = 0;
    for (auto r: sr) {
        for (auto c: gr[r.se]) {
            sc.erase(mp(cntc[c], c));
            cntc[c]--;
            sc.insert(mp(cntc[c], c));
        }
        ans = max(ans, r.fi + (*(sc.rbegin())).fi);
        for (auto c: gr[r.se]) {
            sc.erase(mp(cntc[c], c));
            cntc[c]++;
            sc.insert(mp(cntc[c], c));
        }
    }
    for (auto c: sc) {
        for (auto r: gc[c.se]) {
            sr.erase(mp(cntr[r], r));
            cntr[r]--;
            sr.insert(mp(cntr[r], r));
        }
        ans = max(ans, c.fi + (*(sr.rbegin())).fi);
        for (auto r: gc[c.se]) {
            sr.erase(mp(cntr[r], r));
            cntr[r]++;
            sr.insert(mp(cntr[r], r));
        }
    }
    cout << ans << '\n';
    return 0;
}
//  [c]
#include<stdio.h>
int h[300005], w[300005];
int heap[300005], l;
int cnth[300005], cntw[300005];
int comp_h(int a, int b, int z)
{
	if (z == 0)
	{
		if (h[heap[a]] > h[heap[b]])
			return 1;
		else if (h[heap[a]] < h[heap[b]])
			return -1;
		else if (w[heap[a]] > w[heap[b]])
			return 1;
		else
			return -1;
	}
	else if (z == 1)
	{
		if (cnth[heap[a]] < cnth[heap[b]])
			return 1;
		else
			return -1;
	}
	else
	{
		if (cntw[heap[a]] < cntw[heap[b]])
			return 1;
		else
			return -1;
	}
}
void swap_h(int a, int b)
{
	int f = heap[a];
	heap[a] = heap[b];
	heap[b] = f;
	return;
}
void f1(int ne, int z)
{
	heap[l] = ne;
	int p = l;
	l++;
	while (p > 0)
	{
		if (comp_h((p - 1) / 2, p, z) > 0)
			swap_h((p - 1) / 2, p);
		p = (p - 1) / 2;
	}
	return;
}
int f2(int z)
{
	l--;
	swap_h(0, l);
	int p = 0;
	for (;;)
	{
		if (2 * p + 2 < l)
		{
			if (comp_h(2 * p + 1, 2 * p + 2, z) > 0)
			{
				if (comp_h(p, 2 * p + 2, z) > 0)
					swap_h(p, 2 * p + 2);
				p = 2 * p + 2;
			}
			else
			{
				if (comp_h(p, 2 * p + 1, z) > 0)
					swap_h(p, 2 * p + 1);
				p = 2 * p + 1;
			}
		}
		else if (2 * p + 1 < l)
		{
			if (comp_h(p, 2 * p + 1, z) > 0)
				swap_h(p, 2 * p + 1);
			p = 2 * p + 1;
		}
		else
			break;
	}
	return heap[l];
}
int main()
{
	int H, W, M;
	scanf("%d %d %d", &H, &W, &M);
	int i, j;
	for (i = 0; i < M; i++)
		scanf("%d %d", &h[i], &w[i]);
	l = 0;
	for (i = 0; i < M; i++)
		f1(i, 0);
	int c[300005];
	for (i = 0; i < M; i++)
		c[i] = f2(0);
	for (i = 0; i < H; i++)
		cnth[i] = 0;
	for (i = 0; i < W; i++)
		cntw[i] = 0;
	for (i = 0; i < M; i++)
	{
		cnth[h[i]]++;
		cntw[w[i]]++;
	}
	int hh[300005], ww[300005];
	l = 0;
	for (i = 0; i <= H; i++)
		f1(i, 1);
	for (i = 0; i <= H; i++)
		hh[i] = f2(1);
	l = 0;
	for (i = 0; i <= W; i++)
		f1(i, 2);
	for (i = 0; i <= W; i++)
		ww[i] = f2(2);
	int min, mid, max;
	c[M] = M;
	h[M] = w[M] = -1;
	for (i = 0; cnth[hh[i]] == cnth[hh[0]]; i++)
	{
		for (j = 0; cntw[ww[j]] == cntw[ww[0]]; j++)
		{
			min = -1;
			max = M;
			while (max - min > 1)
			{
				mid = (max + min) / 2;
				if (h[c[mid]] < hh[i])
					min = mid;
				else if (h[c[mid]] > hh[i])
					max = mid;
				else if (w[c[mid]] < ww[j])
					min = mid;
				else
					max = mid;
			}
			if (h[c[max]] != hh[i] || w[c[max]] != ww[j])
			{
				printf("%d\n", cnth[hh[0]] + cntw[ww[0]]);
				return 0;
			}
		}
	}
	printf("%d\n", cnth[hh[0]] + cntw[ww[0]] - 1);
	return 0;
}
//  [javascript]
function Main(input) {
    const lowerBound = (arr, n) => {
        let first = 0, last = arr.length - 1, middle;
        while (first <= last) {
            middle = Math.floor((first + last) / 2);
            if (arr[middle] < n) first = middle + 1;
            else last = middle - 1;
        }
        return first;
    }
    const upperBound = (arr, n) => {
        let first = 0, last = arr.length - 1, middle;
        while (first <= last) {
            middle = Math.floor((first + last) / 2);
            if (arr[middle] <= n) first = middle + 1;
            else last = middle - 1;
        }
        return first;
    }
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    let H = parseInt(input[0][0], 10);
    let W = parseInt(input[0][1], 10);
    let M = parseInt(input[0][2], 10);
    let arr_hw = [];
    let arr_rowCount = Array.from({length: H}, () => []);
    let arr_colCount = Array.from({length: W}, () => []);

    for (let i = 0; i < M; i++){
        arr_hw.push(input[i + 1].map(e => parseInt(e, 10)));
        arr_rowCount[arr_hw[i][0] - 1].push(arr_hw[i][1] - 1);
        arr_colCount[arr_hw[i][1] - 1].push(arr_hw[i][0] - 1);
    }

    // console.log(arr_colCount);
    let MAXrow = 1;
    let tmpRowCandidate = [];
    for (let i = 0; i < H; i++){
        if (arr_rowCount[i].length === MAXrow) {
            tmpRowCandidate.push(i);
        }
        else if (arr_rowCount[i].length > MAXrow) {
            tmpRowCandidate = [i];
            MAXrow = arr_rowCount[i].length;
        }
    }
    let MAXcol = 1;
    let tmpColCandidate = [];
    for (let i = 0; i < W; i++){
        if (arr_colCount[i].length === MAXcol) {
            tmpColCandidate.push(i);
        }
        else if (arr_colCount[i].length > MAXcol) {
            tmpColCandidate = [i];
            MAXcol = arr_colCount[i].length;
        }
    }

    // console.log(tmpRowCandidate);
    // console.log(tmpColCandidate);

    let ans = MAXrow + MAXcol - 1;
    let count = 0;
    for (let hw of arr_hw){
        if (lowerBound(tmpRowCandidate, hw[0] - 1) !== upperBound(tmpRowCandidate, hw[0] - 1) || lowerBound(tmpColCandidate, hw[1] - 1) !== upperBound(tmpColCandidate, hw[1] - 1)){
            // console.log(hw);
            count ++;   
        }
    }
    // console.log(count);
    // console.log(MAXrow * tmpRowCandidate.length + MAXcol * tmpColCandidate.length - tmpRowCandidate.length * tmpColCandidate.length);
    if (count > (MAXrow * tmpRowCandidate.length + MAXcol * tmpColCandidate.length - tmpRowCandidate.length * tmpColCandidate.length)){
        ans ++;
    }

    console.log(ans);

}   

function DFS(tmpNode){
    for (let x of arr_v[tmpNode]){
        if (arr_time[x - 1][1] === 0) {
            arr_time[x - 1] = [x, time, 0];
            time ++;
            history.push(x);
            DFS(x - 1);
        } 
    }
    arr_time[tmpNode][2] = time;
    time ++;
    history.pop();
    return true;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
let [H, W, M] = lines[0].split(' ').map(Number)

const h = Array(H + 1).fill().map((_, i) =>  [0, i])
const w = Array(W + 1).fill().map((_, i) =>  [0, i])

const b = {}

for (let i = 1; i <= M; i++) {
    const p = lines[i].split(' ').map(Number)
    h[p[0]][0]++
    w[p[1]][0]++
    b[p[0] + ':' + p[1]] = 1
}

h.sort((a, b) => b[0] - a[0])
w.sort((a, b) => b[0] - a[0])

const hm = h[0][0]
const hp = []
for (let i = 0; i <= H; i++) {
    if (h[i][0] === hm) {
        hp.push(h[i][1])
    } else {
        break
    }
}

const wm = w[0][0]
const wp = []
for (let i = 0; i <= H; i++) {
    if (w[i][0] === wm) {
        wp.push(w[i][1])
    } else {
        break
    }
}

let c = 1
for (let i = 0; i < hp.length; i++) {
    for (let j = 0; j < wp.length; j++) {
        const index = hp[i] + ':' + wp[j]
        if (!b[index]) {
            c = 0
            break
        }
    }
    if (c === 0) break
}
console.log(hm + wm - c)
//  [javascript]
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var H = one[0];
  var W = one[1];
  var M = one[2];
  var hCount = new Array(H);
  var wCount = new Array(W);
  for(var i = 0; i < H; i++){
    hCount[i] = {
      count : 0,
      no : i
    };
  }
  for(var i = 0; i < W; i++){
    wCount[i] = {
      count : 0,
      no : i
    };
  }
  var mlist = new Set();
  for(var i = 0; i < M; i++){
    var tmp = nextIntArray();
    var l = tmp[0] - 1;
    var r = tmp[1] - 1;
    mlist.add(l + ":" + r);
    hCount[l].count++;
    wCount[r].count++;
  }
  hCount.sort(function(a,b){
    return b.count - a.count;
  });
  wCount.sort(function(a,b){
    return b.count - a.count;
  });
  var hMax = hCount[0].count;
  var wMax = wCount[0].count;
  var output = hMax + wMax - 1;
  var isOK = false;
  for(var i = 0; i < hCount.length; i++){
    if(isOK){
      break;
    }
    if(hCount[i].count < hMax){
      break;
    }
    for(var j = 0; j < wCount.length; j++){
      if(wCount[j].count < wMax){
        break;
      }
      if(!mlist.has(hCount[i].no + ":" + wCount[j].no)){
        output++;
        isOK = true;
        break;
      }
    }
  }
  myout(output);
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	_, _, M := scanInt(), scanInt(), scanInt()
	h, w := make([]int, M), make([]int, M)
	he, we := map[int]int{}, map[int]int{}

	ext := map[pair]bool{}
	for i := 0; i < M; i++ {
		h[i] = scanInt() - 1
		w[i] = scanInt() - 1
		he[h[i]] = -1
		we[w[i]] = -1
		ext[pair{h[i], w[i]}] = true
	}

	hx := []int{}
	wx := []int{}
	for x := range he {
		hx = append(hx, x)
	}
	for x := range we {
		wx = append(wx, x)
	}
	sort.Ints(hx)
	sort.Ints(wx)
	for i := 0; i < len(hx); i++ {
		he[hx[i]] = i
	}
	for i := 0; i < len(wx); i++ {
		we[wx[i]] = i
	}

	hc := make([]int, len(hx))
	wc := make([]int, len(wx))

	for i := 0; i < M; i++ {
		x := he[h[i]]
		y := we[w[i]]
		hc[x]++
		wc[y]++
	}

	ans := 0
	ma := 0
	idh := 0
	for i := 0; i < len(hx); i++ {
		if ma < hc[i] {
			ma = hc[i]
			idh = i
		}
	}

	for i := 0; i < len(wx); i++ {
		t := ma + wc[i]
		if ext[pair{hx[idh], wx[i]}] {
			t--
		}
		ans = max(ans, t)
	}

	ma = 0
	idw := 0
	for i := 0; i < len(wx); i++ {
		if ma < wc[i] {
			ma = wc[i]
			idw = i
		}
	}

	for i := 0; i < len(hx); i++ {
		t := ma + hc[i]
		if ext[pair{hx[i], wx[idw]}] {
			t--
		}
		ans = max(ans, t)
	}
	fmt.Fprintln(wr, ans)

}

type pair struct{ a, b int }
//  [go]
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
  "sort"
)

type Bomb [][]int
func (B Bomb) Len() int { return len(B) }
func (B Bomb) Less(i, j int) bool { return B[i][0] < B[j][0] }
func (B Bomb) Swap(i, j int) { B[i], B[j] = B[j], B[i] }

func Solve() {
  var H, W, M, h, w int
  var ok bool
  NextInt(&H, &W, &M)
  X := make([][]int, H)
  for i := range X { X[i] = []int{0, i} }
  Y := make([][]int, W)
  for i := range Y { Y[i] = []int{0, i} }
  B := make(map[int]map[int]struct{})
  for i := 0; i < M; i++ {
    NextInt(&h, &w)
    h--; w--
    X[h][0]++; Y[w][0]++
    if _, ok = B[h]; !ok { B[h] = make(map[int]struct{}) }
    B[h][w] = struct{}{}
  }
  sort.Sort(sort.Reverse(Bomb(X)))
  sort.Sort(sort.Reverse(Bomb(Y)))
  able, disable := 0, H + M
  L:
    for 1 < disable - able {
      med := (disable + able) / 2
      for _, x := range X {
        for _, y := range Y {
          if x[0] + y[0] > med { able = med; continue L }
          if x[0] + y[0] < med { break }
          if _, ok = B[x[1]]; !ok { able = med; continue L }
          if _, ok = B[x[1]][y[1]]; !ok { able = med; continue L }
        }
      }
      disable = med
    }
  Write(able)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntSlice(A *[]int) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]int, 0)
    return
  }
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatSlice(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  if len(L) == 1 && L[0] == "" {
    (*A) = make([]float64, 0)
    return
  }
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(S ...interface{}) {
  fmt.Fprintln(writer, S...)
}
func WriteIntSlice(A []int) {
  B := make([]interface{}, len(A))
  for i, a := range A { B[i] = a }
  fmt.Fprintln(writer, B...)
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
//  [ruby]
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
      return Array.new(size1){init}
  else
      return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

H,W,M=get_i
we=array(H,0)
he=array(W,0)
kind=Hash.new(0)
M.times do
    h,w=get_i
    h-=1
    w-=1
    we[h]+=1
    he[w]+=1
    kind[h.to_s+":"+w.to_s]+=1
end

ans=0
mh=0
mw=0
H.times do|i|
    mh=i if we[mh]<=we[i]
end
ans=0
W.times do|i|
  v=we[mh]+he[i]-kind[mh.to_s+":"+i.to_s]
  ans=max(ans,v)
end
W.times do|i|
    mw=i if he[mw]<=he[i]
end
H.times do|i|
    v=we[i]+he[mw]-kind[i.to_s+":"+mw.to_s]
    ans=max(ans,v)
end
puts ans
//  [ruby]
input = readlines()

h, w, m = input.shift().chomp().split("\s").map{|x| x.to_i}

h_list = {}
w_list = {}
h_rev = {}
w_rev = {}
pos_list = {}
h_key_max = 0
w_key_max = 0

input.each do |vals|
  ch, cw = vals.chomp.split("\s").map{|x| x.to_i}
  h_list[ch] = 0 if h_list[ch].nil?
  h_list[ch] += 1
  w_list[cw] = 0 if w_list[cw].nil?
  w_list[cw] += 1
  pos_list["#{ch}-#{cw}"] = true

  h_key = h_list[ch]
  w_key = w_list[cw]
  h_rev[h_key] = [] if h_rev[h_key].nil?
  w_rev[w_key] = [] if w_rev[w_key].nil?
  h_rev[h_key].push(ch)
  w_rev[w_key].push(cw)
  h_key_max = h_key if h_key > h_key_max
  w_key_max = w_key if w_key > w_key_max
end

res = [0]
h_rev[h_key_max].each do |tmp_h|
  w_rev[w_key_max].each do |tmp_w|
    cnt = h_list[tmp_h] + w_list[tmp_w]
    if pos_list["#{tmp_h}-#{tmp_w}"] == true
      cnt -= 1
      res.push(cnt)
    else
      puts cnt
      exit()
    end
  end
end

puts res.max
//  [ruby]
require 'pp'
require 'set'

###################

#inputType = :singleLine
# inputType = :2Lines
inputType = :nLines
  
def main(query)
  h,w,m = query.shift

  th = {}
  tw = {}

  query = query.to_set
  
  query.each { | l |
    bh,bw = tois(l.split(" "))
    th[bh] = (th[bh] || 0) + 1
    tw[bw] = (tw[bw] || 0) + 1
  }

  sum = 0

  ppp "th=",th
  ppp "tw=",tw
  ppp "query=",query
  
  hs = th.keys.sort { | a,b | th[b] <=> th[a] }
  maxh = th[hs[0]]
  hs1 = hs.select { | a | th[a] == maxh }
  
  ws = tw.keys.sort { | a,b | tw[b] <=> tw[a] }
  maxw = tw[ws[0]]
  ws1 = ws.select { | a | tw[a] == maxw }

  hs1.each { | h |
    ws1.each { | w |
      k = h.to_s + " " + w.to_s
      if (! query.include?(k)) then
        return [(maxh + maxw)]
      end
    }
  }
  return [(maxh + maxw - 1)]
  
end

###################

TEST=false

def tois(l)
  l.map { | x | x.to_i}
end

def ppp(msg, val)
  if (TEST) then
    print msg
    pp val
  end
end

target = nil
if (ARGV.size == 0) then
  f = STDIN
end
if (ARGV.size > 0) then
  f = open(ARGV[0])
end
if (ARGV.size > 1) then
  target = ARGV[1].to_i
end

t = 1
ng = []
while true
  query = []
  if (inputType == :singleLine) then
    a = f.gets
    if ! a then
      exit
    end
    a.chomp!
    query.push a
  elsif (inputType == :l2Lines) then
    a = f.gets
    if ! a then
      exit
    end
    a.chomp!
    query.push a
    b = f.gets.chomp
    query.push b
  elsif (inputType == :l3Lines) then
    a = f.gets
    if ! a then
      exit
    end
    a.chomp!
    query.push a
    b = f.gets.chomp
    query.push b
    c = f.gets.chomp
    query.push c
  elsif (inputType == :nLines) then
    a = f.gets
    if ! a then
      exit
    end
    a.chomp!
    query.push a    

    n = a.split(" ")[2].to_i

    n.times { | i |
      query.push f.gets.chomp
    }    
  end
  
  aa = f.gets
  if ! aa then
    r = main(query) 
    r.each { | x | puts x }
    exit
  elsif ( aa.chomp == "---") then
    oks = []
    while true
      s = f.gets.chomp
      if (s == "===") then
        break
      end
      oks.push s
    end

    if (target == nil || t == target) then
      if target then
        TEST = true
      end

      puts "--- " + t.to_s + " ---"
      r = main(query)    

      if r.join('\n') == oks.join('\n') then
        puts "RESULT:"
        r.each { | x | puts x }
        puts "OK"
      else
        puts "RESULT:NG"
        r.each { | x | puts x }
        puts "NG!!!!!!!!!"
        ng.push t
      end
    end
  end
  t = t + 1
end
puts "---"
puts "NG targes = " + ng.to_s
//  [rust]
use proconio::input;
use proconio::marker::Usize1;

macro_rules! chmax {
    ($max_v: expr, $v: expr) => {
        if $v > $max_v {
            $max_v = $v;
            true
        } else {
            false
        }
    };
}

fn main() {
    input! {
        _: usize,
        _: usize,
        m: usize,
        hw: [(Usize1, Usize1); m],
    };

    let mut map_h = std::collections::BTreeMap::new();
    let mut map_w = std::collections::BTreeMap::new();
    for (i, &(h_i, w_i)) in hw.iter().enumerate() {
        map_h.entry(h_i).or_insert(vec![]).push(i);
        map_w.entry(w_i).or_insert(vec![]).push(i);
    }

    let ans1 = {
        let mut max_h = 0;
        let mut max_h_i = 0;
        for (h_i, is) in map_h.iter() {
            if chmax!(max_h, is.len()) {
                max_h_i = *h_i;
            }
        }
        let mut max_w = 0;
        for (_, is) in map_w.iter() {
            let len = is.iter().filter(|&&i| hw[i].0 != max_h_i).count();
            chmax!(max_w, len);
        }
        max_h + max_w
    };
    let ans2 = {
        let mut max_w = 0;
        let mut max_w_i = 0;
        for (w_i, is) in map_w.iter() {
            if chmax!(max_w, is.len()) {
                max_w_i = *w_i;
            }
        }
        let mut max_h = 0;
        for (_, is) in map_h.iter() {
            let len = is.iter().filter(|&&i| hw[i].1 != max_w_i).count();
            chmax!(max_h, len);
        }
        max_h + max_w
    };

    let ans = std::cmp::max(ans1, ans2);
    println!("{}", ans);
}
//  [swift]
let HWM = readLine()!.split(separator: " ").compactMap { Int($0) }
let H = HWM[0]
let W = HWM[1]
let M = HWM[2]
let list: [(Int, Int)] = (1...M)
    .map { _ in
        let tmp = readLine()!.split(separator: " ").compactMap { Int($0) }
        return (tmp[0]-1, tmp[1]-1)
    }

var hCounts = Array(repeating: 0, count: H)
var wCounts = Array(repeating: 0, count: W)
var indexes = [String: Bool]()
list.forEach {
    hCounts[$0.0] += 1
    wCounts[$0.1] += 1
    indexes["\($0.0),\($0.1)"] = true
}
let hMax = hCounts.max()!
let wMax = wCounts.max()!

var hMaxIndexes = [Int]()
for i in 0..<hCounts.count {
    if hCounts[i] == hMax {
        hMaxIndexes.append(i)
    }
}
var wMaxIndexes = [Int]()
for i in 0..<wCounts.count {
    if wCounts[i] == wMax {
        wMaxIndexes.append(i)
    }
}

var isExist = false
for i in hMaxIndexes {
    for j in wMaxIndexes {
        if indexes["\(i),\(j)"] != true {
            isExist = true
            break
        }
    }
}

print(isExist ? hMax+wMax : hMax+wMax-1)
//  [python]
n, k = map(int, input().split())
import numpy as np
A = np.zeros(n)
for i in range(k):
  _ = int(input())
  a = np.array(list(map(int, input().split())))
  A[a-1] += 1
print(sum(A == 0))
//  [python]

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

d = []
A = []
for i in range(K):
    d_ = int(input())
    A_ = list(map(int, input().split()))
    d.append(d_)
    A.append(A_)

import numpy as np

S = np.zeros(N)
for i in A:
    for j in i:
        S[j-1] += 1
    
count = 0
for i in S:
    if i == 0:
        count += 1
    
print(count)