Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
x,y = input()

if x < y:
  print("<")
elif x > y:
  print(">")
else:
  print("=")

Fixed submission:
x,y = input().split()

if x < y:
  print("<")
elif x > y:
  print(">")
else:
  print("=")
Buggy python submission (verdict: Runtime Error):
import numpy as np
s = input()
temp = s
temp = temp.replace("x","")
is_rev = True

mirro = []
for i in range(len(temp)//2):
    if temp[i] == temp[-i-1]:
        mirro.append(temp[i])
        continue
    else:
        is_rev = False
if len(temp) %2 == 1:
    mirro.append(temp[len(temp)//2])

if is_rev:
    ind = 0
    i = 0
    lx = np.array([0 for i in range(len(temp)//2+len(temp)%2)])
    rx = np.array([0 for i in range(len(temp)//2+len(temp)%2)])
    temp = 0
    while (True):
        if s[i] == mirro[ind]:
            lx[ind] = temp
            temp = 0
            ind += 1
            i += 1
        else:
            temp += 1
            i += 1

        if ind > len(mirro)-1:
            break
    ind = 0
    i = -1
    temp = 0
    while (True):
        if s[i] == mirro[ind]:
            rx[ind] = temp
            temp = 0
            ind += 1
            i -= 1
        else:
            temp += 1
            i -= 1

        if ind > len(mirro)-1:
            break
    # print(lx)
    # print(rx)
    print(np.sum(np.abs(lx-rx)))
else:
    print(-1)

Fixed submission:
import numpy as np
s = input()
temp = s
temp = temp.replace("x","")
is_rev = True

mirro = []

if len(temp) == 0:
    print(0)
else:
    for i in range(len(temp)//2):
        if temp[i] == temp[-i-1]:
            mirro.append(temp[i])
            continue
        else:
            is_rev = False
    if len(temp) %2 == 1:
        mirro.append(temp[len(temp)//2])

    if is_rev:
        ind = 0
        i = 0
        lx = np.array([0 for i in range(len(temp)//2+len(temp)%2)])
        rx = np.array([0 for i in range(len(temp)//2+len(temp)%2)])
        temp = 0
        while (True):
            if s[i] == mirro[ind]:
                lx[ind] = temp
                temp = 0
                ind += 1
                i += 1
            else:
                temp += 1
                i += 1

            if ind > len(mirro)-1:
                break
        ind = 0
        i = -1
        temp = 0
        while (True):
            if s[i] == mirro[ind]:
                rx[ind] = temp
                temp = 0
                ind += 1
                i -= 1
            else:
                temp += 1
                i -= 1

            if ind > len(mirro)-1:
                break
        # print(lx)
        # print(rx)
        print(np.sum(np.abs(lx-rx)))
    else:
        print(-1)
Buggy python submission (verdict: Time Limit Exceeded):
n,bod = map(int,input().split())
points = []
x = []
y = []
for i in range(n):
    a,b = map(int,input().split())
    x.append(a)
    y.append(b)
    points.append([a,b])

x.sort()
y.sort()


ans = 1e20

for i in range(n):
    for j in range(1,n-i):
        for k in range(n):
            for l in range(1,n-k):
                lef = x[i]
                rig = x[-j]
                bot = y[k]
                top = y[-l]

                cnt = 0
                for m in range(n):
                    if lef <= points[m][0] <= rig and bot <= points[m][1] <= top:
                        cnt += 1
                if cnt >= bod:
                    area = (rig-lef)*(top-bot)
                    if area < ans:
                        ans = area


print(ans)

Fixed submission:
n,bod = map(int,input().split())
points = []
x = []
y = []
for i in range(n):
    a,b = map(int,input().split())
    x.append(a)
    y.append(b)
    points.append([a,b])

x.sort()
y.sort()


ans = 1e20

for i in range(n):
    for j in range(1,n-i):
        for k in range(n):
            for l in range(1,n-k):
                lef = x[i]
                rig = x[-j]
                bot = y[k]
                top = y[-l]

                cnt = 0
                for m in range(n):
                    if lef <= points[m][0] <= rig and bot <= points[m][1] <= top:
                        cnt += 1
                if cnt >= bod:
                    area = (rig-lef)*(top-bot)
                    if area < ans:
                        ans = area


print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations

n,m,rnum = map(int,input().split())
inf = 10**18
shortest = [[inf for i in range(n)] for j in range(n)]
r = list(map(int,input().split()))
for i in range(len(r)):
    r[i]-= 1

for i in range(m):
    a,b,c = map(int,input().split())
    shortest[a-1][b-1] = c
    shortest[b-1][a-1] = c

for i in range(len(shortest)):
    for j in range(len(shortest)):
        for k in range(len(shortest)):
            shortest[j][k] = min(shortest[j][k],shortest[j][i]+shortest[i][k])

ans = inf
# print(shortest)
for p in permutations(r):
    temp = 0
    for i in range(rnum-1):
        temp+=shortest[p[i]][p[i+1]]
    if ans > temp:
        ans = temp
print(ans)

Fixed submission:
from itertools import permutations

n,m,rnum = map(int,input().split())
inf = 10**18
shortest = [[inf for i in range(n)] for j in range(n)]
r = list(map(int,input().split()))
for i in range(len(r)):
    r[i]-= 1

for i in range(m):
    a,b,c = map(int,input().split())
    shortest[a-1][b-1] = c
    shortest[b-1][a-1] = c

for i in range(len(shortest)):
    for j in range(len(shortest)):
        for k in range(len(shortest)):
            shortest[j][k] = min(shortest[j][k],shortest[j][i]+shortest[i][k])

ans = inf
# print(shortest)
for p in permutations(r):
    temp = 0
    for i in range(rnum-1):
        temp+=shortest[p[i]][p[i+1]]
    if ans > temp:
        ans = temp
print(ans)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
s = int(input())
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)
for i in range(1,n):
    t = int(input())
    s = (s*t)//math.gcd_core(s,t)

print(s)

Fixed submission:
n = int(input())
s = int(input())
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)
for i in range(1,n):
    t = int(input())
    s = (s*t)//gcd_core(s,t)

print(s)

Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
s = int(input())
for i in range(1,n):
    t = int(input())
    s = (s*t)//math.gcd(s,t)

print(s)

Fixed submission:
n = int(input())
s = int(input())
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)
for i in range(1,n):
    t = int(input())
    s = (s*t)//gcd_core(s,t)

print(s)
Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
path = {}
for i in range(m):
    a,b = map(int,input().split())
    if a not in path:
        path[a] = [b]
    else:
        path[a].append(b)

ns = []
if 1 in path:
    for p in path[1]:
        ns.append(p)

    flag = False
    for mid in ns:
        if n in path[mid]:
            flag = True
            break

    if flag:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

else:
    print("IMPOSSIBLE")



Fixed submission:
n,m = map(int,input().split())
path = {}
for i in range(m):
    a,b = map(int,input().split())
    if a not in path:
        path[a] = [b]
    else:
        path[a].append(b)

ns = []
if 1 in path:
    for p in path[1]:
        ns.append(p)

    flag = False
    for mid in ns:
        if mid in path:
            if n in path[mid]:
                flag = True
                break

    if flag:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

else:
    print("IMPOSSIBLE")

Buggy python submission (verdict: Runtime Error):
n,m = map(int,input().split())
path = {}
for i in range(m):
    a,b = map(int,input().split())
    if a not in path:
        path[a] = [b]
    else:
        path[a].append(b)

ns = []
for p in path[1]:
    ns.append(p)

flag = False
for mid in ns:
    if n in path[mid]:
        flag = True
        break

if flag:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
        

Fixed submission:
n,m = map(int,input().split())
path = {}
for i in range(m):
    a,b = map(int,input().split())
    if a not in path:
        path[a] = [b]
    else:
        path[a].append(b)

ns = []
if 1 in path:
    for p in path[1]:
        ns.append(p)

    flag = False
    for mid in ns:
        if mid in path:
            if n in path[mid]:
                flag = True
                break

    if flag:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")

else:
    print("IMPOSSIBLE")
Buggy python submission (verdict: Runtime Error):
x = int(iuput())

y = int(x/11)
if x-y*11 < 7:
  print(2*y+1):
else:
  print(2*(y+2))

Fixed submission:
x = int(input())

y = int(x/11)

z = x-11*y

if z == 0:
    print(2*y)
elif z <= 6:
    print(2*y+1)
else:
    print(2*y+2)
Buggy python submission (verdict: Time Limit Exceeded):
a,b,x = map(int,input().split())

ans = 0
for i in range(a,b+1):
    if i%x == 0:
        ans += 1
print(ans)

Fixed submission:
a,b,x = map(int,input().split())
def f(n,x):
    if n == -1:
        return 0
    else:
        return n//x + 1

print(f(b,x)-f(a-1,x))
Buggy python submission (verdict: Runtime Error):

input_array = list(map(int,input().split()))
N = input_array[0]
input_array = list(map(int,input().split()))

num = [1,1,1,1,1,1,1,1,1,1]
ok = []
out = []

for l in range(len(input_array)):
    num[input_array[l]] = 0

for i in range(len(num)):
    if num[i] == 1:
        ok.append(i)

N = list(str(N))

for n in N:
    for m in ok:
        if m >= int(n):
            out.append(m)
            break

for i in range(len(out)-1):
    print(out[i],end="")

print(out[-1])

Fixed submission:

input_array = list(map(int,input().split()))
N = input_array[0]
input_array = list(map(int,input().split()))

num = [1,1,1,1,1,1,1,1,1,1]
ok = []
out = []

for l in range(len(input_array)):
    num[input_array[l]] = 0

for i in range(len(num)):
    if num[i] == 0:
        ok.append(i)

while True:
    key = 0
    for n in list(str(N)):
        if int (n) in ok:
            key += 1
    if key == 0:
        print(N)
        break
    else:
        N+=1
Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split(' '))
A = tuple(map(int, input().split(' ')))

mul = 1
for i in range(K):
    mul *= A[i]

pre = mul

for i in range(K, N):
    mul = pre
    mul //= A[i - K]
    mul *= A[i]
    if mul > pre:
        print('Yes')
    else:
        print('No')
    pre = mul


Fixed submission:
N, K = map(int, input().split(' '))
A = tuple(map(int, input().split(' ')))

for i in range(K, N):
    if A[i] > A[i - K]:
        print('Yes')
    else:
        print('No')

Buggy python submission (verdict: Time Limit Exceeded):
N, K = map(int, input().split(' '))
A = tuple(map(int, input().split(' ')))

mul = 1
for i in range(K):
    mul *= A[i]

pre = mul

for i in range(K, N):
    mul = pre
    mul //= A[i - K]
    mul *= A[i]
    if mul > pre:
        print('Yes')
    else:
        print('No')
    pre = mul


Fixed submission:
N, K = map(int, input().split(' '))
A = tuple(map(int, input().split(' ')))

for i in range(K, N):
    if A[i] > A[i - K]:
        print('Yes')
    else:
        print('No')
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

dp = np.zeros(shape=N + 1, dtype=np.int64)

if 2 * K > N:
    A = [N for _ in range(N)]
else:
    for k in range(K):
        for i in range(N):
            dp[max(0, i - A[i])] += 1
            dp[min(N, i + A[i] + 1)] -= 1
        A = dp.cumsum()[:-1]
        if np.all(A >= N):
            break
        dp *= 0

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


Fixed submission:
import numpy as np

N, K = map(int, input().split(' '))
A = tuple(map(int, input().split(' ')))
indexes = np.arange(0, N)

dp = np.zeros(shape=N + 1, dtype=np.int64)

for k in range(K):
    np.add.at(dp, np.maximum(0, indexes - A), 1)
    np.add.at(dp, np.minimum(N, indexes + A + 1), -1)
    A = dp.cumsum()[:-1]
    if np.all(A == N):
        break
    dp *= 0

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

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

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

dp = np.zeros(shape=N + 1, dtype=np.int64)

for k in range(K):
    for i in range(N):
        dp[max(0, i - A[i])] += 1
        dp[min(N, i + A[i] + 1)] -= 1
    A = dp.cumsum()[:-1]
    if np.all(A >= N):
        break
    dp *= 0

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


Fixed submission:
import numpy as np

N, K = map(int, input().split(' '))
A = tuple(map(int, input().split(' ')))
indexes = np.arange(0, N)

dp = np.zeros(shape=N + 1, dtype=np.int64)

for k in range(K):
    np.add.at(dp, np.maximum(0, indexes - A), 1)
    np.add.at(dp, np.minimum(N, indexes + A + 1), -1)
    A = dp.cumsum()[:-1]
    if np.all(A == N):
        break
    dp *= 0

print(' '.join(map(str, A)))
Buggy python submission (verdict: Time Limit Exceeded):
from functools import reduce
from operator import mul

n = int(input())
numbers = tuple(map(int, input().split(' ')))

n = reduce(mul, numbers)
if n > 10 ** 18:
    print(-1)
else:
    print(n)


Fixed submission:
int(input())
numbers = tuple(map(int, input().split(' ')))

if 0 in numbers:
    print(0)
else:
    mul = 1
    for n in numbers:
        mul *= n
        if mul > 10 ** 18:
            print(-1)
            break
    else:
        print(mul)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
numbers = tuple(map(int, input().split(' ')))

mul = 1
for n in numbers:
    mul *= n

if mul > 10 ** 18:
    print(-1)
else:
    print(mul)


Fixed submission:
int(input())
numbers = tuple(map(int, input().split(' ')))

if 0 in numbers:
    print(0)
else:
    mul = 1
    for n in numbers:
        mul *= n
        if mul > 10 ** 18:
            print(-1)
            break
    else:
        print(mul)
Buggy python submission (verdict: Time Limit Exceeded):
MOD = 998244353

N, S = map(int, input().split(' '))
A = (0, *map(int, input().split(' ')))

dp = []
for _ in range(N + 1):
    dp.append([0] * (S + 1))

dp[0][0] = 1

for i in range(1, N + 1):
    a = A[i]
    for j in range(S + 1):
        dp[i][j] = 2 * dp[i - 1][j] % MOD
        if j >= a:
            dp[i][j] += dp[i - 1][j - a]
            dp[i][j] %= MOD

print(dp[N][S])


Fixed submission:
import numpy as np

MOD = 998244353

N, S = map(int, input().split(' '))
A = (0, *map(int, input().split(' ')))

dp = np.zeros(shape=(N + 1, S + 1), dtype=int)
dp[0][0] = 1

for i in range(1, N + 1):
    a = A[i]
    dp[i] = 2 * dp[i - 1] % MOD
    dp[i][a:] += dp[i - 1][:-a]
    dp[i] %= MOD

print(dp[N][S])
Buggy python submission (verdict: Runtime Error):
def main(n, a):
    indexes = {i + 1 for i in range(n)}
    reduced = set()
    for s in a:
        reduced |= s
    return len(indexes - reduced)


if __name__ == '__main__':
    S = input().rstrip()
    N, K = map(int, input().split())
    A = []
    for _ in range(K):
        input()
        A.append(set(tuple(map(int, input().split(' ')))))
    print(main(N, A))


Fixed submission:
def main(n, a):
    indexes = {i + 1 for i in range(n)}
    reduced = set()
    for s in a:
        reduced |= s
    return len(indexes - reduced)


if __name__ == '__main__':
    N, K = map(int, input().split())
    A = []
    for _ in range(K):
        input()
        A.append(set(tuple(map(int, input().split(' ')))))
    print(main(N, A))

Buggy python submission (verdict: Runtime Error):
def main(n, a):
    indexes = {i + 1 for i in range(n)}
    reduced = set()
    for s in a:
        reduced |= s
    return len(indexes - reduced)


if __name__ == '__main__':
    S = input().rstrip()
    N, K = map(int, input().split())
    A = []
    for _ in range(K):
        input()
        A.append(set(tuple(map(int, input().split(' ')))))
    print(main(N, A))


Fixed submission:
def main(n, a):
    indexes = {i + 1 for i in range(n)}
    reduced = set()
    for s in a:
        reduced |= s
    return len(indexes - reduced)


if __name__ == '__main__':
    N, K = map(int, input().split())
    A = []
    for _ in range(K):
        input()
        A.append(set(tuple(map(int, input().split(' ')))))
    print(main(N, A))
Buggy python submission (verdict: Runtime Error):
import math

R = int(input())

print(R * 2 * math.PI)

Fixed submission:
import math

R = int(input())

print(R * 2 * math.pi)
Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())

r = False
for _ in range(Q):
    query = input()
    if query == '1':
        r ^= True
    else:
        _, f, c = query.split()
        front = f == '1'

        if r ^ front:
            S = c + S
        else:
            S = S + c

if r:
    S = S[::-1]

print(S)


Fixed submission:
S = input()
Q = int(input())

r = False
prefix = []
suffix = []
for _ in range(Q):
    query = input()
    if query == '1':
        r ^= True
    else:
        _, f, c = query.split()
        front = f == '1'

        if r ^ front:
            prefix.append(c)
        else:
            suffix.append(c)

if r:
    S = ''.join(suffix[::-1]) + S[::-1] + ''.join(prefix)
else:
    S = ''.join(prefix[::-1]) + S + ''.join(suffix)

print(S)

Buggy python submission (verdict: Time Limit Exceeded):
S = input()
Q = int(input())

r = False
for _ in range(Q):
    query = input()
    if query == '1':
        r ^= True
    else:
        _, f, c = query.split()
        front = f == '1'

        if r ^ front:
            S = c + S
        else:
            S = S + c

if r:
    S = S[::-1]

print(S)


Fixed submission:
S = input()
Q = int(input())

r = False
prefix = []
suffix = []
for _ in range(Q):
    query = input()
    if query == '1':
        r ^= True
    else:
        _, f, c = query.split()
        front = f == '1'

        if r ^ front:
            prefix.append(c)
        else:
            suffix.append(c)

if r:
    S = ''.join(suffix[::-1]) + S[::-1] + ''.join(prefix)
else:
    S = ''.join(prefix[::-1]) + S + ''.join(suffix)

print(S)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
A = tuple(map(int, input().split(' ')))
MOD = 10 ** 9 + 7


def format2binary(n):
    return list(reversed(format(n, '060b')))


binaries = np.array(list(map(format2binary, A)))

zeros = np.sum((binaries == '0'), axis=0)
ones = np.sum((binaries == '1'), axis=0)

base = 1
ans = 0

for i in range(len(zeros)):
    ans += zeros[i] * ones[i] * base
    ans %= MOD
    base *= 2
    base %= MOD

print(ans)


Fixed submission:
N = int(input())
A = tuple(map(int, input().split(' ')))
MOD = 10 ** 9 + 7

zeros = [0] * 60
ones = [0] * 60

for a in A:
    for i, bit in enumerate(reversed(format(a, '060b'))):
        if bit == '0':
            zeros[i] += 1
        else:
            ones[i] += 1

base = 1
ans = 0

for i in range(len(zeros)):
    ans += zeros[i] * ones[i] * base
    ans %= MOD
    base *= 2
    base %= MOD

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(map(int, input().split(' ')))
MOD = 10 ** 9 + 7

zeros = [0] * 60
ones = [0] * 60

for a in A:
    for i, bit in enumerate(reversed(format(a, '060b'))):
        if bit == '0':
            zeros[i] += 1
        else:
            ones[i] += 1

base = 1
ans = 0

for i in range(len(zeros)):
    ans += zeros[i] * ones[i] * base
    ans %= MOD
    base *= 2
    base %= MOD

print(ans)


Fixed submission:
N = int(input())
A = tuple(map(int, input().split(' ')))
MOD = 10 ** 9 + 7

zeros = [0] * 60
ones = [0] * 60

for a in A:
    for i, bit in enumerate(reversed(format(a, '060b'))):
        if bit == '0':
            zeros[i] += 1
        else:
            ones[i] += 1

base = 1
ans = 0

for i in range(len(zeros)):
    ans += zeros[i] * ones[i] * base
    ans %= MOD
    base *= 2
    base %= MOD

print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from itertools import combinations

N = int(input())
S = input()

s = []
counter = Counter()
for c in S:
    if counter[c] > 3:
        continue
    s.append(c)

print(len(set(combinations(s, r=3))))


Fixed submission:
N = int(input())
S = input()

count = 0
for i in range(1000):
    password = '{:03}'.format(i)
    s = S
    for j in range(3):
        index = s.find(password[j])
        if index == -1:
            break
        s = s[index + 1:]
    else:
        count += 1

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
from itertools import combinations

N = int(input())
S = input()

s = []
counter = Counter()
for c in S:
    if counter[c] > 3:
        continue
    s.append(c)

passwords = set()
for password in combinations(s, r=3):
    passwords.add(''.join(password))

print(len(passwords))


Fixed submission:
N = int(input())
S = input()

count = 0
for i in range(1000):
    password = '{:03}'.format(i)
    s = S
    for j in range(3):
        index = s.find(password[j])
        if index == -1:
            break
        s = s[index + 1:]
    else:
        count += 1

print(count)
Buggy python submission (verdict: Runtime Error):
import collections


def mod_pow(a, n, mod):
    result = 1
    a_n = a
    while n > 0:
        if n & 1:
            result = result * a_n % mod
        a_n = a_n * a_n % mod
        n >>= 1
    return result


def main(n, d):
    MOD = 998244353
    counter = collections.Counter(d)
    if counter[0] != 1:
        return 0
    if 0 in counter.values:
        return 0
    pows = [mod_pow(a=counter[i - 1], n=counter[i], mod=MOD) for i in
            range(1, max(counter.keys()) + 1)]
    patterns = 1
    for p in pows:
        patterns *= p
        patterns %= MOD
    return patterns


if __name__ == '__main__':
    N = int(input())
    D = list(map(int, input().split()))
    print(main(n=N, d=D))


Fixed submission:
import collections


def mod_pow(a, n, mod):
    result = 1
    a_n = a
    while n > 0:
        if n & 1:
            result = result * a_n % mod
        a_n = a_n * a_n % mod
        n >>= 1
    return result


def main(n, d):
    MOD = 998244353
    counter = collections.Counter(d)
    if counter[0] != 1 or d[0] != 0:
        return 0
    pows = [mod_pow(a=counter[i - 1], n=counter[i], mod=MOD) for i in
            range(1, max(counter.keys()) + 1)]
    patterns = 1
    for p in pows:
        patterns *= p
        patterns %= MOD
    return patterns


if __name__ == '__main__':
    N = int(input())
    D = list(map(int, input().split()))
    print(main(n=N, d=D))

Buggy python submission (verdict: Runtime Error):
import collections


def mod_pow(a, n, mod):
    result = 1
    a_n = a
    while n > 0:
        if n & 1:
            result = result * a_n % mod
        a_n = a_n * a_n % mod
        n >>= 1
    return result


def main(n, d):
    MOD = 998244353
    counter = collections.Counter(d)
    pows = [mod_pow(a=counter[i - 1], n=counter[i], mod=MOD) for i in
            max(counter.keys()) + 1]
    patterns = 1
    for p in pows:
        patterns *= p
        patterns %= MOD
    return patterns


if __name__ == '__main__':
    N = int(input())
    D = list(map(int, input().split()))
    print(main(n=N, d=D))


Fixed submission:
import collections


def mod_pow(a, n, mod):
    result = 1
    a_n = a
    while n > 0:
        if n & 1:
            result = result * a_n % mod
        a_n = a_n * a_n % mod
        n >>= 1
    return result


def main(n, d):
    MOD = 998244353
    counter = collections.Counter(d)
    if counter[0] != 1 or d[0] != 0:
        return 0
    pows = [mod_pow(a=counter[i - 1], n=counter[i], mod=MOD) for i in
            range(1, max(counter.keys()) + 1)]
    patterns = 1
    for p in pows:
        patterns *= p
        patterns %= MOD
    return patterns


if __name__ == '__main__':
    N = int(input())
    D = list(map(int, input().split()))
    print(main(n=N, d=D))