Harryxun/stf_run huggingface dataset:
N, M = map(int, input("").split(" "))

A = map(int, input("").split(" "))
A = list(A)
A.sort()

potentials = []
for i in range(M):
    B, C = map(int, input("").split(" "))

    potentials.append((B, C))

potentials.sort(key=lambda x: x[1], reverse=True)

c = 0
for p in potentials:
    for b in range(p[0]):
        if p[1] > A[c]:
            if c < N:
                A[c] = p[1]
                c += 1
            else:
                break
        else:
            break

print(sum(A))


### FIXED CODE ###

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

A = map(int, input("").split(" "))
A = list(A)
A.sort()

potentials = []
for i in range(M):
    B, C = map(int, input("").split(" "))

    potentials.append((B, C))

potentials.sort(key=lambda x: x[1], reverse=True)

c = 0
for p in potentials:
    for b in range(p[0]):
        if p[1] > A[c]:
            A[c] = p[1]
            c += 1
            if c >= len(A):
                break
        else:
            break
    if c >= len(A):
        break

print(sum(A))
N=int(input())
a =[]
for _ in range(0,N):
    a.append(input())
s=0
x=0
b=[0]*(10**9)
for i in range(0,N):
    x=int(a[i])
    if b[x]==0:
        b[x]=1
    else:
        b[x]=0
y=int(max(a))
for i in range(0,y):
    s=s+b[i]
print(s)

### FIXED CODE ###

N=int(input())
a =[]
for _ in range(0,N):
    a.append(int(input()))
b =[]
f=0
s=0
a.sort()
for i in range(0,N):
    if i==0:
        b.append(1)
    elif a[i]==a[i-1]:
        if b[f]==1:
            b[f]=0
        else:
            b[f]=1
    else:
        b.append(1)
        f=f+1
for i in range(0,len(b)):
    s=s+b[i]
print(s)
from math import factorial
 
def comb(n, k):
  return int(factorial(n))/int(factorial(n-k))/int(factorial(k))
 
N, K = map(int, input().split())
 
for i in range(1, K+1):
  if N-K-i+1 < 0:
    print(0)
  else:
    a = comb(N-K+1, i)%(10**9+7)
    b = comb(K-1, i-1)%(10**9+7)
    print(int((a*b)%(10**9+7)))

### FIXED CODE ###

from math import factorial
 
def comb(n, k):
  return int(factorial(n))//int(factorial(n-k))//int(factorial(k))
 
N, K = map(int, input().split())
 
for i in range(1, K+1):
  if N-K-i+1 < 0:
    print(0)
  else:
    a = comb(N-K+1, i)%(10**9+7)
    b = comb(K-1, i-1)%(10**9+7)
    print(int((a*b)%(10**9+7)))
import math
n,m=map(int,input().split())
s=list(input())
t=list(input())
num=(n*m)//math.gcd(n,m)
str1=[0]*num
ans=num
numn=num//n
numm=num//m
for i in range(n):
    str1[i*(numn)]=s[i]
for i in range(m):
    str2=str1[i*numm]
    if str2!=0 and str2!=t[i]:
        ans=-1
        break
print(ans)


### FIXED CODE ###

import math
n,m=map(int,input().split())
s=list(input())
t=list(input())
num=math.gcd(n,m)
ans=(n*m)//num
numn=n//num
numm=m//num
for i in range(num):
    if s[i*numn]!=t[i*numm]:
        ans=-1
        break
print(ans)
a=map(int,input().split())
for i in range(len(a)):
  if a[i]!=i:
    print(a[i])

### FIXED CODE ###

a=list(map(int,input().split()))
for i in range(5):
  if a[i]!=i+1:
    print(i+1)
n,m=map(int,raw_input())
mul1=mul2=1
if abs(n-m)>1:
    print 0
else:
    for i in range(1,n+1):
        mul1*=i
        mul1%=mod
    for i in range(1,m+1):
        mul2*=i
        mul2%=mod
    if n==m:
        print (2*mul1*mul2)%mod
    else:
        print (mul1*mul2)%mod

### FIXED CODE ###

mod=10**9+7
n,m=map(int,raw_input().split())
mul1=mul2=1
if abs(n-m)>1:
    print 0
else:
    for i in range(1,n+1):
        mul1*=i
        mul1%=mod
    for i in range(1,m+1):
        mul2*=i
        mul2%=mod
    if n==m:
        print (2*mul1*mul2)%mod
    else:
        print (mul1*mul2)%mod
import numpy as np

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

K_str = format(K, 'b')
max_order = len(K_str)

B = np.array([list(format(a, '0{}b'.format(10)))
              for a in A]
             ).astype('i')[:,:10]
B = B.sum(axis=0)
B = np.where(B < N/2, 1, 0)

X_str = ''.join(map(str, B))
X = int(X_str, 2)

print(sum(map(lambda a: X ^ a, A)))


### FIXED CODE ###

import numpy as np

N, K = [int(a) for a in input().split()]
A = [int(a) for a in input().split()]

K = format(K, 'b')
B = [format(a, 'b') for a in A]
max_order = len(max(B + [K], key=len))

K = K.zfill(max_order)
B = np.array([list(b.zfill(max_order)) for b in B], dtype='i')
B = B.sum(axis=0)
B = np.where(B < N/2, '1', '0')

for i, k, b in zip(range(max_order), K, B):
    if k < b:
        B[i] = '0'
    elif k > b:
        break

X = int(''.join(map(str, B)), 2)

print(sum(map(lambda a: X ^ a, A)))
a=int(input())
b=[i for i in range(a)]
c=int(sum(b))
print(c)

### FIXED CODE ###

n=list(input())
s=list(input())
g=0
for i in range(3):
    if n[i]==s[i]:
        g+=1

print(g)
N,M,X = map(int, input().split())
a = input().split()
a += str(X) 
b = sorted(a).index(str(X))
if b <= (len(a)-1-b):
    print(b)
else:
    print(len(a)-1-b)

### FIXED CODE ###

n,m,x=map(int,input().split())
s=sum(int(i)<x for i in input().split())
print(min(s,m-s))
S = list(input())

cnt = 0

for i in range(len(S)):
  if S[i] == 'R':
	  if cnt == 0:
    	cnt += 1
  	  elif S[i - 1] == 'R':
      	cnt += 1

print(cnt)

### FIXED CODE ###

S = list(input())

cnt = 0

for i in range(len(S)):
  if S[i] == 'R':
    if cnt == 0:
      cnt += 1
    elif S[i - 1] == 'R':
      cnt += 1

print(cnt)
a=int(input("Enter a number")
b=int(input("Enter b")
c=(int(input("Enter C")
if a-b == b-c || b-a == c-b:
 print ("Beautiful")
else :
 print("No")


### FIXED CODE ###

a,b,c=map(int,input().split())
if b-a == c-b:
    print("YES")
else:
    print("NO")
#! python3
#  solve127A.py

age,cost = map(int,input().split())

if age <= 5:
    cost = 0
elif 6 <= age <= 12:
    cost = cost//2
elif 7 <= age:
    cost = cost

print(cost)

### FIXED CODE ###

r,D,x =map(int,input().split())
 
for i in range(10):
	x = r*x-D
	print(x)
N=input()

math.ceil(N)

### FIXED CODE ###

N=int(input())
import math
ans=math.ceil(N/2)
print(ans)
from collections import Counter

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

flag="No"

count_by_kw = Counter()
for i in range(n):
    count_by_kw[a[i]]+=1

if count_by_kw.get(0) == n:
    flag="Yes"

if count_by_kw.get(0) == n/3 and len(count_by_kw.keys())==2:
    flag="Yes"

cl=list(count_by_kw.values())
ck=list(count_by_kw.values())

if len(cl)==3:
    if cl[0] == cl[1] and cl[1] == cl[2]:
        if ck[0]^ck[1]^ck[2]^ == 0
            flag="Yes"
        
print(flag)





### FIXED CODE ###

from collections import Counter

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

flag="No"

count_by_kw = Counter()
for i in range(n):
    count_by_kw[a[i]]+=1

if count_by_kw.get(0) == n:
    flag="Yes"

if count_by_kw.get(0) == n/3 and len(count_by_kw.keys())==2:
    flag="Yes"

cl=list(count_by_kw.values())
ck=list(count_by_kw.keys())

if len(cl)==3:
    if cl[0] == cl[1] and cl[1] == cl[2]:
        xor = ck[0]^ck[1]^ck[2]
        if xor == 0:
            flag="Yes"
        
print(flag)
n = int(input())
p = [int(input()) for i in range(n)]

print(int(sum(p)-max(p)/2))

### FIXED CODE ###

D = input()

if D == "25":
    print("Christmas\n")
elif D == "24":
    print("Christmas Eve\n")
elif D == "23":
    print("Christmas Eve Eve\n")
else:
    print("Christmas Eve Eve Eve\n")
H, W = [int(_) for _ in input().split()]
S = [input() for _ in range(H)]

move = ((1, 0), (-1, 0), (0, 1), (0, -1))

visited = [[False] * W for _ in range(H)]

b, w = 0, 0

def dfs(i, j):
    global b, w, visited

    if visited[i][j]:
        return
    visited[i][j] = True

    if S[i][j] == '#':
        b += 1
    else:
        w += 1

    for di, dj in move:
        ni, nj = i + di, j + dj
        if 0 <= ni < H and 0 <= nj < W and S[i][j] != S[ni][nj]:
            dfs(ni, nj)


result = 0
for i in range(H):
    for j in range(W):
        b, w = 0, 0
        dfs(i, j)
        result += b * w
print(result)



### FIXED CODE ###

from collections import deque


H, W = [int(_) for _ in input().split()]
S = [input() for _ in range(H)]


di = (1, 0, -1, 0)
dj = (0, 1, 0, -1)

def is_valid(i, j, d):
    ni = i + di[d]
    nj = j + dj[d]
    if not (0 <= ni < H and 0 <= nj < W):
        return False
    if S[i][j] == S[ni][nj]:
        return False
    return True


result = 0
visited = [[False] * W for _ in range(H)]
for i in range(H):
    for j in range(W):

        if visited[i][j]:
            continue
        visited[i][j] = True

        b = 0
        w = 0
        que = deque()
        que.append((i, j))
        while que:
            (ci, cj) = que.pop()
            if S[ci][cj] == '#':
                b += 1
            else:
                w += 1

            for d in range(4):
                if not is_valid(ci, cj, d):
                    continue
                ni = ci + di[d]
                nj = cj + dj[d]
                if visited[ni][nj]:
                    continue
                visited[ni][nj] = True
                que.append((ni, nj))

        result += b * w


print(result)
# coding: utf-8
 
N  = int(input())
sum_pre = 0
sum = 1
 
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
def gcd_list(numbers):
    return reduce(math.gcd, numbers)
 
for x in range(N):  
    for i in range (N):
        for j in range(N):
            for k in range(N):
                sum_pre += gcd(*[i, j, k])
     sum += sum_pre
 
print(sum)

### FIXED CODE ###

# coding: utf-8
 
N  = int(input())
sum = 0
 
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
 
for i in range (N):
    for j in range(N):
        for k in range(N):
            sum += gcd(*[i+1, j+1, k+1])
 
print(sum)
# coding: utf-8

N, Q = map(int, input().split())
S = input()


num = [0] * (N+1)
i = 0
for i in range(N):
    if S[i]=='A' and S[i+1]=='C':
        num[i + 1] = num[i] + 1
    else:
        num[i + 1] = num[i]

        

for i in range(Q):
    l, r = map(int, input().split())
    print( num[r-1] - num[l-1] )


### FIXED CODE ###

# coding: utf-8

N, Q = map(int, input().split())
S = input()

num = [0] * (N+1)

for i in range(N):
    #if S[i]=='A' and S[i+1]=='C':
    if S[i:i+2] =='AC':
        num[i + 1] = num[i] + 1
    else:
        num[i + 1] = num[i]

        

for i in range(Q):
    l, r = map(int, input().split())
    print( num[r-1] - num[l-1] )
N=int(input())
A=list(input().split())

shusseki_jun=[' ' for _ in range(N)]
for i in range(N):
    ind = A[i]
    shusseki_jun[int(ind)-1] = str(i+1)

print(' '.join(shusseki_jun))


### FIXED CODE ###

N=int(input())
if N%2 ==0:
    print(0.5)
else:
    print((N//2+1)/N)
import itertools
import sys
sys.setrecursionlimit(2000)
h, w = map(int, input().split())
s_list = []
for i in range(h):
  s_list.append(list(input()))
res = 0
check_list = set()

def rec_create_area(point, tmp_area, current_str):
  new_point_list = []
  new_point_list.append((point[0] + 1, point[1]))
  new_point_list.append((point[0], point[1] + 1))
  new_point_list.append((point[0] - 1, point[1]))
  new_point_list.append((point[0], point[1] - 1))
  for new_point in new_point_list:
    if new_point[0] >= h or new_point[1] >= w or new_point[0] < 0 or new_point[1]  < 0:
      continue
    if new_point in check_list:
      continue
    new_str = s_list[new_point[0]][new_point[1]]
    if new_str == current_str:
      continue
    if new_str == "#":
      tmp_area[0] += 1
    else:
      tmp_area[1] += 1
    check_list.add(new_point)
    rec_create_area(new_point, tmp_area, new_str)
  
for a, b in itertools.product(range(h), range(w)):
  check_point = (a, b)
  if check_point in check_list:
    continue
  check_list.add(check_point)
  current_str = s_list[0][0]
  if current_str == "#":
    tmp_area = [1, 0]
  else:
    tmp_area = [0, 1]
  rec_create_area(check_point, tmp_area, current_str)
  res += tmp_area[0] * tmp_area[1]
  
print(res)

### FIXED CODE ###

import itertools
import sys
sys.setrecursionlimit(1000000)
h, w = map(int, input().split())
s_list = []
for i in range(h):
  s_list.append(list(input()))
res = 0
check_list = set()

def rec_create_area(point, tmp_area, current_str):
  new_point_list = []
  new_point_list.append((point[0] + 1, point[1]))
  new_point_list.append((point[0], point[1] + 1))
  new_point_list.append((point[0] - 1, point[1]))
  new_point_list.append((point[0], point[1] - 1))
  for new_point in new_point_list:
    if new_point[0] >= h or new_point[1] >= w or new_point[0] < 0 or new_point[1]  < 0:
      continue
    if new_point in check_list:
      continue
    new_str = s_list[new_point[0]][new_point[1]]
    if new_str == current_str:
      continue
    if new_str == "#":
      tmp_area[0] += 1
    else:
      tmp_area[1] += 1
    check_list.add(new_point)
    rec_create_area(new_point, tmp_area, new_str)
  
for a, b in itertools.product(range(h), range(w)):
  check_point = (a, b)
  if check_point in check_list:
    continue
  check_list.add(check_point)
  current_str = s_list[check_point[0]][check_point[1]]
  if current_str == "#":
    tmp_area = [1, 0]
  else:
    tmp_area = [0, 1]
  rec_create_area(check_point, tmp_area, current_str)
  res += tmp_area[0] * tmp_area[1]
  
print(res)
while True:

    x = input()

    if x == 0:
        break

    length = len(x)
    tot = 0

    for i in range(length):
        tot += int(x[i:i + 1])
    print(tot)


### FIXED CODE ###

while True:

    x = input()

    if x == '0':
        break

    length = len(x)
    tot = 0

    for i in range(length):
        tot += int(x[i:i + 1])
    print(tot)
nm = [int(i) for i in input().split()]
n = nm[0]
m = nm[1]
slist = []
clist = []
for i in range(m):
  sc = [int(i) for i in input().split()]
  slist.append(sc[0])
  clist.append(sc[1])

if (n == 1):
  if (slist[0] == 1 and clist[0] == 0):
    print('-1')

answerlist = ['-1' for i in range(n)]
for (i,s), c in zip(enumerate(slist),clist):
  if (c == 0 and s == 1):
    print('-1')
    exit()
  if (answerlist[s-1] != '-1' and answerlist[s-1] != str(c)):
    print('-1')
    exit()
  answerlist[s-1] = str(c)
for i in range(n):
  if (answerlist[i]) == '-1':
    if (i == 0):
      answerlist[i] = '1'
    else:
      answerlist[i] = '0'
print("".join(answerlist))

### FIXED CODE ###

nm = [int(i) for i in input().split()]
n = nm[0]
m = nm[1]
slist = []
clist = []

for i in range(m):
  sc = [int(i) for i in input().split()]
  slist.append(sc[0])
  clist.append(sc[1])

fl = 0
if (n == 1):
  if m != 0:
    if (slist[0] == 1 and clist[0] == 0):
      print('0')
      fl = 1
      exit()

answerlist = ['-1' for i in range(n)]
for (i,s), c in zip(enumerate(slist),clist):
  if (c == 0 and s == 1):
    print('-1')
    fl = 1
    exit()
  if (answerlist[s-1] != '-1' and answerlist[s-1] != str(c)):
    print('-1')
    fl = 1
    exit()
  answerlist[s-1] = str(c)
for i in range(n):
  if (answerlist[i]) == '-1':
    if (i == 0):
      if (n == 1):
        answerlist[i] = '0'
      else:
        answerlist[i] = '1'
    else:
      answerlist[i] = '0'
if fl == 0:
	print("".join(answerlist))
b = input()

if b == 'A'{
  print('T')
}else if b =='T'{
  print('A')
}else if b == 'C'{
  print('C')
}else{
  print('G')
}

### FIXED CODE ###

b = input()
 
if b == 'A':
  print('T')
elif b =='T':
  print('A')
elif b == 'C':
  print('G')
else:
  print('C')
a = 'abcdefghijklmnopqrstuvwxyz'
b = [0 for i in range(len(a))]
while True:
	S = raw_input().lower()
	if S == "":
		break
	for j in range(26):
		b[j] += S.count(a[j])
for i in range(len(a)):
	print str(a[i])+" : "+str(b[i])

### FIXED CODE ###

a = 'abcdefghijklmnopqrstuvwxyz'
b = [0 for i in range(len(a))]
while True:
	try:
		S = raw_input().lower()
	except:
		break
	for j in range(26):
		b[j] += S.count(a[j])
for i in range(len(a)):
	print str(a[i])+" : "+str(b[i])
N, K, S = map(int, input().split())
 
ans = []

if S == 10**9:
    ans = [s for _ in range(K)] + [1] * (N - K)
else:
    ans = [s for _ in range(K)] + [S + 1] * (N - K)

print(' '.join(map(str, result)))

### FIXED CODE ###

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

if S == 10**9:
    ans = [S for _ in range(K)] + [1] * (N - K)
else:
    ans = [S for _ in range(K)] + [S + 1] * (N - K)

print(' '.join(map(str, ans)))
from math import gcd

A, B, C, D = map(int, input().split())

np = (B - A + 1) + (-(B - A) // C)
nq = (B - A + 1) + (-(B - A) // D)


def coprime(a, b):
    return gcd(a, b) == 1


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


if coprime(C, D) == True:
    npq = (B - A + 1) + (-(B - A) // (C * D))
    print(np + nq - npq)
else:
    npq_ = (B - A + 1) + (-(B - A) // lcm(C, D))
    print(np + nq - npq_ - 1)

### FIXED CODE ###

from fractions import gcd

A, B, C, D = map(int, input().split())


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


nbc = B - B // C
nbd = B - B // D
nbl = B - B // lcm(C, D)

nac = A - 1 - ((A - 1) // C)
nad = A - 1 - ((A - 1) // D)
nal = A - 1 - ((A - 1) // lcm(C, D))

b = nbc + nbd - nbl
a = nac + nad - nal

print(b - a)
A11, A12, A13=list(map(int,input().split()))
A21, A22, A23=list(map(int,input().split()))
A31, A32, A33=list(map(int,input().split()))
N=int(input())
b=[input() for i in range(N)]
if A11, A12, A13 in b:
    print('Yes')
elif A21, A22, A23 in b:
    print('Yes')
elif A31, A32, A33 in b:
    print('Yes')
elif A11, A21, A31 in b:
    print('Yes')
elif A12, A22, A32 in b:
    print('Yes')
elif A13, A23, A33 in b:
    print('Yes')
elif A11, A22, A33 in b:
    print('Yes')
elif A13, A22, A31 in b:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

A11, A12, A13=list(map(int,input().split()))
A21, A22, A23=list(map(int,input().split()))
A31, A32, A33=list(map(int,input().split()))
N=int(input())
b=[int(input()) for i in range(N)]
if A11 in b and A12 in b and A13 in b:
    print('Yes')
elif A21 in b and A22 in b and A23 in b:
    print('Yes')
elif A31 in b and A32 in b and A33 in b:
    print('Yes')
elif A11 in b and A21 in b and A31 in b:
    print('Yes')
elif A12 in b and A22 in b and A32 in b:
    print('Yes')
elif A13 in b and A23 in b and A33 in b:
    print('Yes')
elif A11 in b and A22 in b and A33 in b:
    print('Yes')
elif A13 in b and A22 in b and A31 in b:
    print('Yes')
else:
    print('No')
K = int(input())
S = input()

if len(S) < K:
    print(s)
else:
    print(s[:k] + "...")

### FIXED CODE ###

k = int(input())
s = input()
n = len(s)
     
if n <= k:
	print(s)
else:
	print(s[:k] + '...')
# coding: utf-8
# Your code here!

import math
import sys

N, M = map(int, input().rstrip().split(' '))
S = [x for x in input()]
T = [x for x in input()]

def lcm(x, y):
    return int((x * y) / math.gcd(x, y))
    
L = lcm(N, M)

if S[0] != T[0]:
    print(-1)
    #sys.exit()
elif L == N or L == M:
    dp = [-1] * L
    for i, s in enumerate(S):
        dp[i*L/N] = s
        
    for i, t in enumerate(T):
        if dp[i*L/M] != -1 and dp[i*L/M] != t:
            print(-1)
            #sys.exit()
else:
    print(L)

### FIXED CODE ###

# coding: utf-8
# Your code here!

import fractions
import sys
from collections import defaultdict

N, M = map(int, input().rstrip().split(' '))
S = [x for x in input()]
T = [x for x in input()]

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

L = lcm(N, M)

dp = defaultdict(lambda: -1)

for i, s in enumerate(S):
    dp[i*L//N] = s

for i, t in enumerate(T):
    if dp[i*L//M] != -1:
        if dp[i*L//M] != t:
            print(-1)
            sys.exit()
print(L)
a, b = map(int, input().split())

if a => 13:
  print(b)
elif 12 >= a and a >= 6:
  print(b/2)
elif a <= 5:
  print(0)

### FIXED CODE ###

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

if 13 <= a:
  print(b)
elif 6 <= a and a <= 12:
  print(int(b/2))
elif a <= 5:
  print(0)
import heapq

n, m = map(int, input().split())
prices = [int(p) for p in input().split()]
heapq._heapify_max(prices)
for _ in range(m):
    p = heapq._heappop_max(prices) // 2
    prices.append(p)
    heapq._siftdown_max(prices, 0, n - 1)
print(sum(prices))

### FIXED CODE ###

import heapq

n, m = map(int, input().split())
prices = [-int(p) for p in input().split()]
heapq.heapify(prices)
for _ in range(m):
  p = heapq.heappop(prices)
  heapq.heappush(prices, p / 2)
print(-sum(int(p) for p in prices))
n = int(input())
if n == 3 or n == 5 or b == 7:
    print("YES")
else:
    print("NO")

### FIXED CODE ###

n = int(input())
if n == 3 or n == 5 or n == 7:
    print("YES")
else:
    print("NO")
import numpy as np

H, W, M = map(int, input().split())
map_ = np.zeros((H, W), dtype=np.uint8)

h_sum = [0] * H
w_sum = [0] * W

for _ in range(M):
    h, w = map(int, input().split())
    map_[h-1, w-1] = 1
    h_sum[h-1] += 1
    w_sum[w-1] += 1

ans = 0
h_max = max(h_sum)
w_max = max(w_sum)

h_argmax = set()
w_argmax = set()

for i, h in enumerate(h_sum):
    if h == h_max:
        h_argmax.add(i) 

for i, w in enumerate(w_sum):
    if w == w_max:
        w_argmax.add(i)

ans = h_max + w_max

for h in h_argmax:
    for w in w_argmax:
        if map_[h, w] == 0:
            print(ans)
            exit()
print(ans - 1)

### FIXED CODE ###

# import numpy as np

H, W, M = map(int, input().split())
#map_ = np.zeros((H, W), dtype=np.bool)

h_sum = [0] * H
w_sum = [0] * W
point_list = set()

for _ in range(M):
    h, w = map(int, input().split())
    # map_[h-1, w-1] = 1
    point_list.add((h-1, w-1))
    h_sum[h-1] += 1
    w_sum[w-1] += 1

h_max = max(h_sum)
w_max = max(w_sum)

h_argmax = set()
w_argmax = set()

for i, h in enumerate(h_sum):
    if h == h_max:
        h_argmax.add(i) 

for i, w in enumerate(w_sum):
    if w == w_max:
        w_argmax.add(i)

ans = h_max + w_max

for h in h_argmax:
    for w in w_argmax:
        if (h, w) not in point_list:
        # if map_[h, w] == 0:
            print(ans)
            exit()
print(ans - 1)
n, x, t = map(int, input().split())

print((n//=x + 1) * t )

### FIXED CODE ###

n, x, t = map(int, input().split())
a = n // x
if n % x == 0:
  print(a * t)
else:
  print((a + 1) * t)
import math
a,b=map(int, input().split())
print((a*b)//math.gcd(a,b))

### FIXED CODE ###

import fractions
a,b=map(int, input().split())
print((a*b)//fractions.gcd(a,b))
def quicksort(lst):
	if lst == []: return []
	elif len(lst) == 1: return lst
	else:
		pivot = lst[0][0]
		leftlist = []
		rightlist = []
		for i in range(0, len(lst)):
			if lst[i][0] < pivot:
				leftlist.append(lst[i])
			else:
				rightlist.append(lst[i])
		newleft = quicksort(leftlist)
		newright = quicksort(rightlist)
		newleft.extend(newright)
		return newleft

N, M = map(int, raw_input().split())
drinklist = []
for i in range(0, N):
	drinklist.append(map(int, raw_input().split()))
drinklist = quicksort(drinklist)

sum = 0
drink = M
for i in range(0, N):
	if drink < drinklist[i][1]:
		sum += drink * drinklist[i][0]
		break
	else:
		sum += drinklist[i][1] * drinklist[i][0]
		drink -= drinklist[i][1]

print sum

### FIXED CODE ###

from operator import itemgetter

N, M = map(int, raw_input().split())
drinklist = []
for i in range(0, N):
	drinklist.append(map(int, raw_input().split()))
drinklist = sorted(drinklist, key=itemgetter(0))
sum = 0
drink = M
for i in range(0, N):
	if drink < drinklist[i][1]:
		sum += drink * drinklist[i][0]
		break
	else:
		sum += drinklist[i][1] * drinklist[i][0]
		drink -= drinklist[i][1]

print sum
a = int(input())
ar = list(map(int,input().split(" ")))
br = []
for r in ar:
    if r % 2 == 0:
        br.append(r)
count = 0
br.sort()
while len(br) != 0:
    t = len(br) - 1
    br = [j * 3 if i != t else j / 2 for i,j in enumerate(br)]
    count += 1
    if br[t] % 2 == 1:
        del br[t]
print(count)

### FIXED CODE ###

a = int(input())
ar = list(map(int,input().split(" ")))
br = []
for r in ar:
    if r % 2 == 0:
        br.append(r)
count = 0
for r in br:
    while r % 2 != 1:
        r /= 2
        count += 1
print(count)
import math
N = int(input())
ans = 10

for i in reversed(range(1,int(math.sqrt(N)) + 1)):
    if N % i == 0:
        A = len(str(i))
        B = len(str(N //  i))
        print (N // i)
        ans = min(ans,max(A,B))

print(ans)


### FIXED CODE ###

A,B = (map(int, input().split()))
print (A + B if A + B < 24 else A + B - 24)
S = input()
if S = 'SSS':
  a = 0
if S = 'SSR':
  a = 1
if S = 'SRS':
  a = 1
if S = 'SRR':
  a = 2
if S = 'RSS':
  a = 1
if S = 'RSR':
  a = 1
if S = 'RRS':
  a = 2
if S = 'RRR':
  a = 3
print(a)
  

### FIXED CODE ###

S = input()
if S == 'SSS':
  a = 0
if S == 'SSR':
  a = 1
if S == 'SRS':
  a = 1
if S == 'SRR':
  a = 2
if S == 'RSS':
  a = 1
if S == 'RSR':
  a = 1
if S == 'RRS':
  a = 2
if S == 'RRR':
  a = 3
print(a)