Harryxun/stf_run huggingface dataset:
# -*- coding: utf-8 -*-
from collections import Counter as C

h, w, m = map(int, input().split())

hs, ws = [], []
hw = []

for i in range(m):
    hi, w = map(int, input().split())
    hs.append(hi)
    ws.append(w)
    hw.append([hi, w])


ch = C(hs).most_common()
cw = C(ws).most_common()
anss = []
pre_ans = -float('inf')
mrow = ch[0][0]
mcow = cw[0][0]

for num1, num2 in zip(ch, cw):
    row, cow = num1[0], num2[0]
    if mrow > row and mcow > cow:
        break
    ans1 = hs.count(row)
    ans2 = ws.count(cow)
    ans = ans1 + ans2

    if [row, cow] in hw:
        ans -= 1

    anss.append(ans)


print(max(anss))


### FIXED CODE ###

import math
n, x, t = map(int, input().split())

y = math.ceil(n / x) * t
print(int(y))
S = input()
ans = 700
for i in range S:
  if i == "o":
    ans += 100
  if i == "x":
    ans += 0
print(ans)


### FIXED CODE ###

S = input()
ans = 700
for i in S:
  if i == "o":
    ans += 100
  if i == "x":
    ans += 0
print(ans)
import sys

def process(data):
	count = 0

	M = int(data[0])
	D = data[1]

	if len(D) < 2:
		return 0


	for d10 in range(2, int(D[0])+1):
		for d1 in range(2, 10):
			if 0 < d10 * d1 and d10 * d1 <= M and int(str(d10)+str(d1)) <= int(D):
				count += 1


	return count 

def main(argv):
	data = []
	for i, v in enumerate(argv):
		data.append(v)
	#print(process(data))
	return process(data)

if __name__ == '__main__':
    main(sys.argv[1:])

### FIXED CODE ###

import sys

def process(data):
	count = 0

	M = int(data[0])
	D = data[1]
	
	if len(D) < 2:
		return 0


	for d10 in range(2, int(D[0])+1):
		for d1 in range(2, 10):
			if 0 < d10 * d1 and d10 * d1 <= M:
				if int(str(d10)+str(d1)) <= int(D):
					count += 1
				else:
					break


	return count 

def main(argv):
	for i in range(1):
		data = raw_input()
		data = data.split(" ")
	print(process(data))

	

if __name__ == '__main__':
    main(sys.argv[1:])
from fractions import Fraction


N = int(input())

AB = [tuple(map(int, input().split())) for _ in range(N)]

MOD = 10**9 + 7

from collections import defaultdict

d = defaultdict(int)
ans = 1
cnt_00 = 0
for a,b in AB:
    if a == 0 and b == 0:
        cnt_00 += 1 
    elif a == b:
        d[1] += 1
    else:
        d[Fraction(a,b)] += 1




ans = 1
ks = list(d.keys())
for k in ks:
    if d[k] == 0:
        continue
    
    elif k == 1 or k == -1:

        num = pow(2,d[1]) + pow(2, d[-1])-1
        ans *= num
        ans %= MOD
        d[1] = 0
        d[-1] = 0

    else:

        num = pow(2, d[k]) + pow(2,d[Fraction(-1, k)])-1
        ans *= num
        ans %= MOD
        d[k] = 0
        d[Fraction(-1, k)] = 0
        



ans -=1
ans %= MOD
print(ans) 

### FIXED CODE ###

from math import gcd
from collections import defaultdict

N = int(input())
AB = [tuple(map(int, input().split())) for _ in range(N)]
MOD = 10**9 + 7

d = defaultdict(int)
cnt_00 = 0
cnt_0b = 0
cnt_a0 = 0
for a,b in AB:
    if a == b == 0:
        cnt_00 += 1
    elif a == 0:
        cnt_a0 += 1
    elif b == 0:
        cnt_0b += 1
    else:
        num_gcd = gcd(a,b)
        grad = 1 if a * b > 0 else -1
        a //= num_gcd
        b //= num_gcd
        d[(grad, abs(a), abs(b))] += 1



ans = 1
for k in d.keys():
    if d[k] == 0:
        continue
    
    grad, a, b = k[0], k[1], k[2]
    if (-grad, b, a) in d:
        
        # 傾き a/bのものを一つ以上選ぶ場合（-b/aは選ばない） + -b/aから一つ以上選ぶ場合（a/bは選ばない） + どちらからも選ばない場合
        ans *= (pow(2, d[(grad, a, b)], MOD)-1) + (pow(2, d[(-grad, b, a)], MOD)-1) + 1
        ans %= MOD
        d[(grad, a, b)] = 0
        d[(-grad, b, a)] = 0
    else:
        # a/bから0個以上選ぶ場合
        ans *= pow(2, d[(grad, a, b)], MOD)
        ans %= MOD
        d[(grad, a, b)] = 0

# a,bの一方のみ0の場合 + どちらからも選ばない場合
ans *= (pow(2, cnt_a0, MOD)-1) + (pow(2, cnt_0b, MOD)-1) + 1
ans %= MOD

# 0,0のみを１つだけ入れる場合
ans += cnt_00
# なにも選ばない場合を除く
ans -= 1

ans %= MOD

print(ans)
n = list(map(int, input().split()))
if n[0] == n[1]:
    if n[0] == n[2]:
    print("Yes")
print("No")

### FIXED CODE ###

n = list(map(int, input().split()))
if n[0] != n[1]:
    if n[1] == n[2]:
        print("Yes")
        exit()
    if n[0] == n[2]:
        print("Yes")
        exit()
    if n[0] != n[2]:
        print("No")
        exit()
if n[0] == n[1]:
    if n[0] != n[2]:
        print("Yes")
        exit()
print("No")
a, b = map(int(input().split())

if a < b:
    print("a < b")

elif a > b:
    print("a > b")

else:
    print("a == b")



### FIXED CODE ###

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

if a < b:
    print("a < b")

elif a > b:
    print("a > b")

else:
    print("a == b")
S = str(input())
s = int(S)
n = len(S)
count = 0
for i in range(1,n+1):
    for j in range(i+4,n+1):
        si = s%10**(n-i+1)
        sij = si//10**(n-j)
        if sij % 2019 == 0:
            count+=1
            i+=4
            j+=4

print(count)


### FIXED CODE ###

S,W = map(int,input().split())
if S>W:
  print('safe')
else:
  print('unsafe')
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)

s = input()

K = []
for k in range(1, len(s)):
    if s[k] != s[k-1]:
        K.append(max(len(s)-k, k))
    else:
        continue

ans = 0
if min(K) == 0:
    if all(v == "1" for v in s):
        ans = len(s)
else:
    ans = min(K)
print(ans)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**9)

s = input()

K = float('inf')
if all(c == '0' for c in s):
    K = len(s)
elif all(c == '1' for c in s):
    K = len(s)
else:
    for k in range(1, len(s)):
        if s[k] != s[k-1]:
            K = min(K, max(k, len(s)-k))
        else:
            continue

print(K)
import itertools

N, M = map(int, input().split())
graph = [[0] * N for i in range(N)]
for i in range(N):
    a, b = map(int, input().split())
    graph[a-1][b-1] = 1
    graph[b-1][a-1] = 1

p = list(itertools.permutations(range(N)))

Sum = 0

for i in range(len(p)):
    if p[i][0] != 0:
        break
    for j in range(N - 1):
        if graph[p[i][j]][p[i][j + 1]] != 1:
            break
        if j == N - 2:
            Sum += 1

print(Sum)




### FIXED CODE ###

import itertools

N, M = map(int, input().split())
graph = [[0] * N for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    graph[a-1][b-1] = 1
    graph[b-1][a-1] = 1

p = list(itertools.permutations(range(N)))

Sum = 0

for i in range(len(p)):
    if p[i][0] != 0:
        break
    for j in range(N - 1):
        if graph[p[i][j]][p[i][j + 1]] != 1:
            break
        elif j == N - 2:
            Sum += 1

print(Sum)
from collections import defaultdict
N = int(input())
g = [[] for i in range(N)]
 
for i in range(N-1):
    a,b = list(map(int,input().split()))
    a,b = a-1,b-1
    g[a] += [b]
    g[b] += [a]
    
def bfs(g, st):
    queue = [st]
    distances = [-1 for i in range(N)]
    distances[st] = 0
    
    while queue:
        node = queue.pop(0)
        for h in g[node]:
            if distances[h] == -1:
                distances[h] = distances[node] + 1
                queue += h
 
    return distances
 
dB = bfs(g, 0)
dW = bfs(g, N-1)
 
B, W = 0, 0
for i in range(N):
    if dB[i] <= dW[i]:
        B += 1
    else:
        W += 1
print("Fennec" if B > W else "Snuke")

### FIXED CODE ###

from collections import defaultdict
N = int(input())
g = [[] for i in range(N)]
 
for i in range(N-1):
    a,b = list(map(int,input().split()))
    a,b = a-1,b-1
    g[a] += [b]
    g[b] += [a]
    
def bfs(g, st):
    queue = [st]
    distances = [-1 for i in range(N)]
    distances[st] = 0
    
    while queue:
        node = queue.pop(0)
        for h in g[node]:
            if distances[h] == -1:
                distances[h] = distances[node] + 1
                queue += [h]
 
    return distances
 
dB = bfs(g, 0)
dW = bfs(g, N-1)
 
B, W = 0, 0
for i in range(N):
    if dB[i] <= dW[i]:
        B += 1
    else:
        W += 1
print("Fennec" if B > W else "Snuke")
from math import gcd
A, B, C, D = list(map(int, input().split()))
num_B_C = B // C
num_B_D = B // D
lcm_C_D = int(C * D / gcd(C, D))
num_B = B - (num_B_C + num_B_D) + B // lcm_C_D

num_A_C = (A-1) // C
num_A_D = (A-1) // D
num_A = (A-1) - (num_A_C + num_A_D) + (A-1) // lcm_C_D

ans = num_B - num_A
print(ans)

### FIXED CODE ###

from fractions import gcd
A, B, C, D = list(map(int, input().split()))
num_B_C = B // C
num_B_D = B // D
lcm_C_D = int(C * D / gcd(C, D))
num_B = B - (num_B_C + num_B_D) + B // lcm_C_D

num_A_C = (A-1) // C
num_A_D = (A-1) // D
num_A = (A-1) - (num_A_C + num_A_D) + (A-1) // lcm_C_D

ans = num_B - num_A
print(ans)
in = list(map(int,input().split()))

in.sort()

if in=[5,5,7] : 
  print( 'Yes' )
else : 
  print( 'No' )  

### FIXED CODE ###

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

a.sort()

if a == [5,5,7] : 
  print( "YES" )
else :
  print( "NO" )
import sys
def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(var):
	print(var, file=sys.stderr)

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
from math import gcd
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br

a = []
a.append(I()[0])
a.append(I()[0])
for i in range(1, 4):
	if i not in a:
		print(i)
		break


### FIXED CODE ###

import sys
def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(var):
	print(var, file=sys.stderr)

INF = 10**20
MOD = 10**9 + 7
I = lambda:list(map(int,input().split()))
# from math import gcd
# from collections import defaultdict as dd, Counter
# from bisect import bisect_left as bl, bisect_right as br

a = []
a.append(I()[0])
a.append(I()[0])
for i in range(1, 4):
	if i not in a:
		print(i)
		break
a=int(input())
b=int(input())
print(6-(a+b))

### FIXED CODE ###

S=input()
if S=='hi' or S=='hihi' or S=='hihihi' or S=='hihihihi' or S=='hihihihihi':
  print("Yes")
else:
  print("No")
import copy

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def gcdm(x):
	g=x[0]
	for i in range(1,len(x)):
		g=gcd(g,x[i])
	return(g)

def score(A):
	return(sum(A)-len(A))

def Ifavor(A):
	return(score(A)%2==1)	

def playmove(A,i):
	A[i]-=1
	g=gcdm(A)
	A=[x//g for x in A]
	
def testmove(A,i):
	N=len(A)
	A[i]-=1
	g=gcdm(A)
	A=[x//g for x in A]
	if Ifavor(A):
		A=[x*g for x in A]
		A[i]+=1
		return(False)
	else:
		j=0
		while j<N:
			A[j]-=1
			h=gcdm(A)	
			if Ifavor([x//h for x in A])==False:
				A[j]+=1
				A=[x*g for x in A]
				A[i]+=1
				return(False)
			A[j]+=1
			j+=1
		A=[x*g for x in A]
		A[i]+=1	
		return(True)

N=int(input())
B=[int(x) for x in input().split()]

#inp=St.splitlines()
#N=int(inp[0])
#B=[int(x) for x in inp[1].split()]

if Ifavor(B):
	print('First')
else:
	maxply=sum(B)-N
	ply=1
	e=0
	while e<N:
		if testmove(B,e):
			break
		e+=1
			
	if e!=N:
		playmove(B,e)
		ply+=1

	if (ply%2==1)!=Ifavor(B):
		print('Second')
	else:
		print('First')
	

### FIXED CODE ###

import random
def tester(N=0):
	'''制約
1≦N≦105
1≦Ai≦109
'''
	maxno1=1e5
	maxno2=1e9
	s=input()
	if s!='':return(s)
	
	if N==0:
		return(random.randint(2,maxno1))
	else:
		print('Testing...')
		print('N=',N)
		A=[]
		for i in range(N):
			A.extend([random.randint(1,maxno2)])
		return(' '.join(list(map(str,A))))

import copy

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def gcdm(x):
	g=x[0]
	for i in range(1,len(x)):
		if g==1:
			return(g)
		g=gcd(g,x[i])
	return(g)

def playmove(A,i):
	A[i]-=1
	g=gcdm(A)
	return([x//g for x in A])

def noofevens(A):
	r=0
	for i in A:
		if i%2==0:
			r+=1
	return(r)
			

N=int(tester())
A=[int(x) for x in tester(N).split()]


isFirstmove=True
while True:
	e=noofevens(A)
	if e%2==1:
		if isFirstmove:
			print('First')
		else:
			print('Second')
		break
	elif N-e>1:
		if isFirstmove:
			print('Second')
		else:
			print('First')
		break
	else:	
		for i in range(N):
			if A[i]%2==1:
				break
		if A[i]==1:
			if isFirstmove:
				print('Second')
			else:
				print('First')
			break
		else:
			A=playmove(A,i)
			isFirstmove=(isFirstmove!=True)
import numpy as np

N, X = map(int, input().split())
S = list(map(int, input().split()))

MOD = 1000000007
numbers = S[:]
numbers.sort()


dp = np.zeros((N+1, X+1), dtype=int)
dp = np.arange(X+1)
dp_n = []
for n  in numbers:
    dp_n = np.zeros((X+1), dtype=np.int64)
    dp_n += [dp[x % n] for x in range(X+1)]
    dp_n = dp_n % MOD
    dp_n += dp * i % MOD
    dp_n = dp_n % MOD
    dp = dp_n

print(int(dp_n[X]) % MOD)


### FIXED CODE ###

N, X = map(int, input().split())
S = list(map(int, input().split()))

MOD = 1000000007
numbers = S[:]
numbers.sort(reverse=True)


dp = {X: 1}

for i, n in enumerate(numbers):
    tmp_dp = {}
    for k, v in dp.items():
        if k < n:
            tmp_dp[k] = (tmp_dp.get(k,0)+v*(N-i))
        else:
            tmp_dp[k]=(tmp_dp.get(k,0)+v*(N-i-1)) 
            tmp_dp[k%n]=(tmp_dp.get(k%n,0)+v) 
    dp = tmp_dp.copy()
        
ans = 0
for k, v in dp.items():
    ans += k *  v

print(ans % MOD)
def main():
    X=int(input())
    start=0
    while(True):
        back=X-pow(start,5)
        A_back=int(pow(back,1/5))

        front=X+pow(start,5)
        A_front=int(pow(front,1/5))
        if(pow(A_back,5)==back):
            A=A_back
            B=-start
            break
        elif(pow(A_front,5)==front):
            A=A_front
            B=start
            break
        else:
            start+=1
    print(A,B)
if __name__=='__main__':
    main()

### FIXED CODE ###

def main():
    X=int(input())
    start=0
    back=-1
    while(True):
        back=X-pow(start,5)
        if back>0:
            A_back=int(pow(back,1/5))
        else:
            A_back=-int(pow(-back,1/5))

        front=X+pow(start,5)
        if front>0:
            A_front=int(pow(front,1/5))
        else:
            A_front=-int(pow(-front,1/5))
        if(pow(A_back,5)==back):
            A=A_back
            B=-start
            break
        elif(pow(A_front,5)==front):
            A=A_front
            B=start
            break
        else:
            start+=1
    print(A,B)
if __name__=='__main__':
    main()
N=int(input())
A=[int(input())-1 for _ in range(N)]
result=[]
app=result.append
def next(k):
	print(result,k)
	newlight=A[k]
	if k==1:
		return(1)
	elif k in result:
		return(0)
	else:
		app(k)
		return(next(newlight))
if not next(0):
	print(-1)
else:print(len(result))

### FIXED CODE ###

import sys
sys.setrecursionlimit(500000)
N=int(input())
A=[int(input())-1 for _ in range(N)]
result=[False]*N
def next(k):
	newlight=A[k]
	if k==1:
		return(1)
	elif result[k]:
		return(0)
	else:
		result[k]=True
		return(next(newlight))
if not next(0):
	print(-1)
else:print(sum(result))
MB_TLE = 0
MB_WA = 0
MB_RE = o
MB_AC = 0
n=int(input())
for i in range (n):
    ch = input ()
    if (ch =="TLE")
     MB_TLE += 1
      if (ch =="WA")
     MB_WA += 1
    if (ch =="RE")
     MB_RE += 1
      if (ch =="AC")
     MB_AC += 1
print('TLE x',MB_TLE)
print('WA x',MB_WA)
print('RE x',MB_RE)
print('AC x',MB_AC)

### FIXED CODE ###

MB_AC = 0
MB_WA = 0
MB_TLE = 0
MB_RE = 0
n = int(input())
for i in range (n):
    ch = input ()
    if (ch =="AC") :
     MB_TLE += 1
    if (ch =="WA") :
     MB_WA += 1
    if (ch =="TLE") : 
     MB_RE += 1
    if (ch =="RE") :
     MB_AC += 1
print('AC x ',MB_TLE)
print('WA x ',MB_WA)
print('TLE x ',MB_RE)
print('RE x ',MB_AC)
a,b,c = map(int,input().split())

if a=5 b=5 c=7 or a=5 b=7 c=5 or a=7 b=5 c=5:
  print("YES")
  
else:
  print("NO")

### FIXED CODE ###

  
  # 文節の入力(整数として扱う)
a, b, c = map(int, input().split())
# まず長さが7の文節があるか確認
if a == 7 and b == 5 and c == 5:
	print("YES")
elif a == 5 and b == 7 and c == 5:
	print("YES")
elif a == 5 and b == 5 and c == 7:
	print("YES")
else:
	print("NO")
a,b,c,d=map(int,input().split())
cd=[c,d]
cd.sort()
l=b-a+1

def func(n,m):
    if m%n!=0:
        return m//n+1
    else:
        return m//n

def func2(x,y):
    ans=x%y
    x=y
    y=ans
    while True:
        ans=x%y
        if ans==0:
            return y
        x=y
        y=ans
cd2=cd[1]*cd[0]//(func2(cd[1],cd[0]))
print(l-(func(c,l)+func(d,l)-func(cd2,l)))


### FIXED CODE ###

import fractions
a,b,c,d=map(int,input().split())
lcm=c*d//fractions.gcd(c,d)
print(b-a+1-((b//c-(a-1)//c)+(b//d-(a-1)//d)-(b//lcm-(a-1)//lcm)))
n=int(input())
v=list(map(int,input().split()))


A=[0]*(10**1)
B=[0]*(10**1)


for i in range(n):
    if i%2==0:
        A[v[i]-1]+=1
    else:
        B[v[i]-1]+=1
x=n//2-max(A)
y=n//2-max(B)
AA=''.join(map(str,A))
BB=''.join(map(str,B))
a=AA.find(str(max(A)))
b=BB.rfind(str(max(B)))
if a!=b:
    print(x+y)




### FIXED CODE ###

n=int(input())
v=list(map(int,input().split()))
import collections

if len(set(v))==1:
    print(n//2)
else:
    a=[]
    b=[]
    for i in range(n):
        if i%2==0:
            a.append(v[i])
        else:
            b.append(v[i])
    a=collections.Counter(a)
    a0=a.most_common()[0]
    b=collections.Counter(b)
    b0=b.most_common()[0]
    if a0[0]!=b0[0]:
        print(n-a0[1]-b0[1])
    elif a0[0]==b0[0]:
        if a0[1]>b0[1]:
            print(n-a0[1]-b.most_common()[1][1])
        elif a0[1]<b0[1]:
            print(n-b0[1]-a.most_common()[1][1])
        elif a0==b0:
            if b.most_common()[1][1]>=a.most_common()[1][1]:
                print(n-a0[1]-b.most_common()[1][1])
            elif b.most_common()[1][1]<=a.most_common()[1][1]:
                print(n-b0[1]-a.most_common()[1][1])
def main():
    A = input()
    B = input()

    if A == "1" and B == "2":
        ans = 3
    elif A == "2" and B == "3":
        ans = 1
    elif A == "3" and B == "1":
        ans = 2

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    A = int(input())
    B = int(input())

    ans = 6 - A - B

    print(ans)


if __name__ == "__main__":
    main()
def construct_table(n, s):
    table = [-1] * (n + 1)
    j = -1
    for i in range(n):
        while j >= 0 and s[i] != s[j]:
            j = table[j]
        j += 1
        table[i + 1] = j
    return table


n = int(input())
m = n
a = list(map(int, input().split()))
t = list(map(int, input().split()))
s2 = a + a
tb = construct_table(m, t)
l = [False] * n
i = 0
j = 0
while i < n:
    if t[j] == s2[i + j]:
        i += j - tb[j]
        if j > 0:
            j = tb[j]
    else:
        j += 1
        if j == m:
            l[i] = True
            i += j - tb[j]
            j = tb[j]
if True in l:
    print('Yes')
    idx = l.index(True)
    print(*(t[n-idx:]+t[:n-idx]))
else:
    print('No')
    exit(1)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
be = [-1] * n
la = [-1] * n
be2 = [-1] * n
la2 = [-1] * n
for i in range(n):
    if be[a[i] - 1] == -1:
        be[a[i] - 1] = i
    la[a[i] - 1] = i + 1
    if be2[b[i] - 1] == -1:
        be2[b[i] - 1] = i
    la2[b[i] - 1] = i + 1
l, r = 0, 2 * n
for i in range(n):
    if la[i] != -1 and la2[i] != -1:
        l = max(la[i] - be2[i], l)
        r = min(r, be[i] + n - la2[i])
if l > r:
    print('No')
else:
    print('Yes')
    print(*(b[n-l:] + b[:n-l]))
from math import factorial
import collections
N, *s = open(0).read().split()
s_sorted = [''.join(sorted(c)) for c in s]
c = collections.Counter(s_sorted)
res = list(set(s_sorted))
count = 0
for s in res:
  if c[s] > 2:
    count += factorial(c[s]) / factorial(2) / factorial(c[s] - 2)
  elif c[s] == 2:
    count += 1
print(count)

### FIXED CODE ###

N, *s = open(0).read().split()
sl = [''.join(sorted(c)) for c in s]
count = 0
dict = {}
for s in sl:
  if s in dict:
    count += dict[s]
    dict[s] += 1
  else:
    dict[s] = 1
print(count)
N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
else:
    mod = 998244353
    D.sort()
    ans = 1
    distance = 0
    prev = 1
    now = 0
    for i in range(len(D)):
        if D[i] == distance:
            now += 1
        elif D[i] == distance + 1:
            ans = ans * prev ** now % mod
            prev = now+0
            now = 1
            distance += 1
        else:
            ans = 0
            break
    else:
        ans = ans * prev ** now % mod

print(ans)

### FIXED CODE ###

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

if D[0] != 0:
    print(0)
else:
    D.sort()

    if D[1] == 0:
        print(0)
    else:
        mod = 998244353
        ans = 1
        distance = 0
        prev = 1
        now = 0

        for i in range(N):
            if D[i] == distance:
                now += 1
            elif D[i] == distance + 1:
                ans = (ans % mod) * (prev ** now % mod) % mod
                prev = now+0
                now = 1
                distance += 1
            else:
                ans = 0
                break
        else:
            ans = (ans % mod) * (prev ** now % mod) % mod
        
        print(ans)
import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n = int(input())
    x, l = [0]*n, [0]*n
    for i in range(n):
        x[i], l[i] = map(int, input().split())
    hoge = []
    for i in range(n):
        hoge.append(x+l)
    t = 0
    for i in range(n):
        if t < hoge[i]:
            ans += 1
            t = hoge[i]
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

### FIXED CODE ###

import numpy as np
import functools
import math
import scipy
import fractions
import itertools

def solve():
    n = int(input())
    x, l = [0]*n, [0]*n
    for i in range(n):
        x[i], l[i] = map(int, input().split())
    hoge = []
    for i in range(n):
        hoge.append([x[i]+l[i], x[i]-l[i]])
    hoge.sort()
    t = -1000000000000000000000
    ans = 0
    for i in range(n):
        if t <= hoge[i][1]:
            ans += 1
            t = hoge[i][0]
    print(ans)
    return 0

if __name__ == "__main__":
    solve()
p, q, r = map(int, input().split())
print(min([p+q, q+r, r+p])

### FIXED CODE ###

p, q, r = map(int, input().split())
print(min([p+q, q+r, r+p]))
n,m = map(int,input().split())
a = list(map(int,input().split()))
lis = [1] + [0]*n

for i in a:
  lis[i]=-1
lis[1] += 1
for i in range(n-1):
  if lis[i+2]==-1:
    lis[i+2]= 0
  else:
    lis[i+2] = lis[i+1] + lis[i]
print(lis[n])

### FIXED CODE ###

n,m = map(int,input().split())
a = [ int(input()) for _ in range(m)]
M=10**9+7
lis = [1] + [0]*n

for i in a:
  lis[i]=-1
lis[1] += 1
for i in range(n-1):
  if lis[i+2]<0:
    lis[i+2]= 0
  else:
    lis[i+2] = (lis[i+1] + lis[i])%M
print(lis[n])
# encoding: utf-8
N, K = map(int, input().split())
D = list(map(int, input().split()))

Db = []
for Di in range(10):
    if Di not in D: Db.append(Di)
# print("#", Db)

for level in range(6):
    if N // (10 ** level) < 1: break
# print("#", level)
    
memo = [None] * (level * 10000)
    
def pay(pos, tmp):
    # print("##", pos, tmp)
    if pos > level or tmp >= N:
        if tmp >= N:
            # print("###", tmp)
            return tmp
        else: return 10000
    elif memo[pos * 10000 + tmp] != None: return memo[pos * 10000 + tmp]
    rets = []
    for Dbi in Db:
        add = Dbi * (10 ** pos)
        rets.append(pay(pos + 1, tmp + add))
    ret = min(rets)
    if memo[pos * 10000 + tmp] == None: memo[pos * 10000 + tmp] = ret    
    return ret

print(pay(0, 0))

### FIXED CODE ###

# encoding: utf-8
N, K = map(int, input().split())
D = list(map(int, input().split()))

Db = []
for Di in range(10):
    if Di not in D: Db.append(Di)
# print("#", Db)

for level in range(6):
    if N // (10 ** level) < 1: break
# print("#", level)
    
memo = [None] * ((level + 1) * 10000)
    
def pay(pos, tmp):
    # print("##", pos, tmp)
    if pos > level or tmp >= N:
        if tmp >= N:
            # print("###", tmp)
            return tmp
        else: return 10000
    elif memo[pos * 10000 + tmp] != None: return memo[pos * 10000 + tmp]
    rets = []
    for Dbi in Db:
        add = Dbi * (10 ** pos)
        rets.append(pay(pos + 1, tmp + add))
    ret = min(rets)
    if memo[pos * 10000 + tmp] == None: memo[pos * 10000 + tmp] = ret    
    return ret

print(pay(0, 0))