Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
s = input()
l = 0
r = len(s)-1
c = 0
while l < r:
  c_l = 0
  c_r = 0
  while s[l] == "x":
    c_l += 1
    l += 1
  while s[r] == "x":
    c_r += 1
    r -= 1
  if s[l] != s[r]:
    print(-1)
    exit()
  c += abs(c_l-c_r)
  l += 1
  r -= 1
print(c)

Fixed submission:
s = input()
l = 0
r = len(s)-1
c = 0
if s.count("x") == len(s):
  print(0)
  exit()
while l < r:
  c_l = 0
  c_r = 0
  while s[l] == "x":
    c_l += 1
    l += 1
  while s[r] == "x":
    c_r += 1
    r -= 1
  if s[l] != s[r]:
    print(-1)
    exit()
  c += abs(c_l-c_r)
  l += 1
  r -= 1
print(c)
Buggy python submission (verdict: Time Limit Exceeded):
from itertools import permutations
n,m,r = map(int,input().split())
rl = list(map(int,input().split()))
d = [[10**8]*n for i in range(n)]
for i in range(m):
  a,b,c = map(int,input().split())
  d[a-1][b-1] = d[b-1][a-1] = c
for i in range(n):
  for j in range(n):
    for k in range(n):
      d[i][j] = min(d[i][j],d[i][k]+d[k][j])
m = 10**9
for i in permutations(rl):
  c = 0
  for j in range(1,r):
    c += d[i[j-1]-1][i[j]-1]
  m = min(m,c)
print(m)

Fixed submission:
from itertools import permutations
n,m,r = map(int,input().split())
rl = list(map(int,input().split()))
d = [[10**8]*n for i in range(n)]
for i in range(m):
  a,b,c = map(int,input().split())
  d[a-1][b-1] = d[b-1][a-1] = c
for k in range(n):
  for i in range(n):
    for j in range(n):
      d[i][j] = min(d[i][j],d[i][k]+d[k][j])
m = 10**9
for i in permutations(rl):
  c = 0
  for j in range(1,r):
    c += d[i[j-1]-1][i[j]-1]
  m = min(m,c)
print(m)
Buggy python submission (verdict: Runtime Error):
s=input()
t=s.reverse()
if s==t:
  print("Yes")
else:
  print("No")

Fixed submission:
from copy import deepcopy as dp
s=list(input())
t=dp(s)
s.reverse()
if s==t:
  print("Yes")
else:
  print("No")
Buggy python submission (verdict: Runtime Error):
w = input()
for i in w:
  if w.coount(i) % 2:
    print('No')
    exit()
print('Yes')

Fixed submission:
w = input()
for i in w:
  if w.count(i) % 2:
    print('No')
    exit()
print('Yes')
Buggy python submission (verdict: Runtime Error):

a = int(input())
lists = list(map(int, input().split())) #１行の入力をi[0],i[1]というように空白で分けてを取得し、iに値を入れる

num = [0]*a

def mi(x):

    
    return int(x-1)

y = list(map(mi,lists))

for i in range(a):
    #print('y')
   # print(i)
    num[y[i]] += 1
for i in range(a):
    print(num[i])
    


Fixed submission:
a = int(input())
lists = list(map(int, input().split())) #１行の入力をi[0],i[1]というように空白で分けてを取得し、iに値を入れる

num = [0]*a

def mi(x):

    
    return int(x-1)

y = list(map(mi,lists))

for i in range(a-1):
    num[y[i]] += 1
for i in range(a):
    print(num[i])

Buggy python submission (verdict: Runtime Error):

a = int(input())
lists = list(map(int, input().split())) #１行の入力をi[0],i[1]というように空白で分けてを取得し、iに値を入れる

num = [0]*a

def mi(x):

    
    return int(x-1)

y = list(map(mi,lists))
print(y)
for i in range(a):
    #print('y')
   # print(i)
    num[y[i]] += 1
for i in range(a):
    print(num[i])
    

Fixed submission:
a = int(input())
lists = list(map(int, input().split())) #１行の入力をi[0],i[1]というように空白で分けてを取得し、iに値を入れる

num = [0]*a

def mi(x):

    
    return int(x-1)

y = list(map(mi,lists))

for i in range(a-1):
    num[y[i]] += 1
for i in range(a):
    print(num[i])
Buggy python submission (verdict: Runtime Error):
#キューを使っている。ところどころマイナスにしているのはキューの性質のため。実行時間が全然違うのはソートが早いから
n,m = map(int,input().split())
a = list(map(lambda x: -int(x) ,input().split()))
print(a)
import heapq
heapq.heapify(a)
for _ in range(m):
  tmp = -heapq.heappop(a)
  tmp //= 2
  heapq.heappush(a,-tmp)
print(-sum(a))

Fixed submission:
from sys import stdin

a = stdin.readline().rstrip()
if a == "Sunny":
  print("Cloudy")
elif a== "Cloudy":
   print("Rainy")
else:
   print("Sunny")

Buggy python submission (verdict: Runtime Error):
l = stdin.readline().rstrip().split()
print(l)

Fixed submission:
from sys import stdin

a = stdin.readline().rstrip()
if a == "Sunny":
  print("Cloudy")
elif a== "Cloudy":
   print("Rainy")
else:
   print("Sunny")
Buggy python submission (verdict: Time Limit Exceeded):
n,m=(int(x) for x in input().split())
import math as math
import numpy as np

ans = 0
A = [int(x) for x in input().split()]

for i in range(m):
    A.sort()
    A [-1] = A[-1]/2
for i in range(n):
   A[i] =  math.floor(A[i]) 
   ans += A[i]
print(ans)


Fixed submission:
#キューを使っている。ところどころマイナスにしているのはキューの性質のため。実行時間が全然違うのはソートが早いから
n,m = map(int,input().split())
a = list(map(lambda x: -int(x) ,input().split()))

import heapq
heapq.heapify(a)
for _ in range(m):
  tmp = -heapq.heappop(a)
  tmp //= 2
  heapq.heappush(a,-tmp)
print(-sum(a))

Buggy python submission (verdict: Time Limit Exceeded):
n,m=(int(x) for x in input().split())
import math as math
import numpy as np


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

for i in range(m):
    A.sort()
    A [-1] = A[-1]/2
for i in range(n):
   A[i] =  math.floor(A[i]) 
print( sum(int(i) for i in A))


Fixed submission:
#キューを使っている。ところどころマイナスにしているのはキューの性質のため。実行時間が全然違うのはソートが早いから
n,m = map(int,input().split())
a = list(map(lambda x: -int(x) ,input().split()))

import heapq
heapq.heapify(a)
for _ in range(m):
  tmp = -heapq.heappop(a)
  tmp //= 2
  heapq.heappush(a,-tmp)
print(-sum(a))
Buggy python submission (verdict: Runtime Error):
import numpy as np  # NumPyモジュールをインポートする
import itertools

val = input()
val = val.split(" ")
val = [int(i) for i in val]  # 全部intに変換

I = np.zeros((val[0], val[1]+1))

for i in range(val[0]):
    val2 = input()
    val2 = val2.split(" ")
    val2 = [int(i) for i in val2]  # 全部intに変換
    I[i] = val2

seq = [i for i in range(val[0])]  # 組み合わせを考える
print(seq)

for i in range(val[0]):
    Comb = list(itertools.combinations(seq, i+1))
    # print(Comb)
    for j in Comb:
        Com_list = list(j)
        # print(Com_list)
        I_sum = [[I[k][l+1] for k in Com_list] for l in range(val[1])]
        print(I_sum)
        ans = [sum(i) for m in I_sum]
        print('ans=', ans)
        # if (ans >= 10):
        #     print(I[Com_list])


Fixed submission:
import numpy as np  # NumPyモジュールをインポートする
import itertools

val = input()
val = val.split(" ")
val = [int(i) for i in val]  # 全部intに変換

I = np.zeros((val[0], val[1]+1))

for i in range(val[0]):
    val2 = input()
    val2 = val2.split(" ")
    val2 = [int(i) for i in val2]  # 全部intに変換
    I[i] = val2

seq = [i for i in range(val[0])]  # 組み合わせを考える
# print(seq)

ans = []

for i in range(val[0]):
    Comb = list(itertools.combinations(seq, i+1))
    # print(Comb)
    for j in Comb:
        Com_list = list(j)
        # print(Com_list)
        I_sum = [[I[k][l+1] for k in Com_list] for l in range(val[1])]
        # print(I_sum)
        I_sum_over_x = [sum(m) for m in I_sum if sum(m) >= val[2]]
        # print('I_sum_over_x=', I_sum_over_x)
        if(len(I_sum_over_x) == val[1]):
            # print("xxx=", j)
            I_sum2 = [I[n][0] for n in list(j)]
            # print(I_sum2)
            # print(sum(I_sum2))
            ans.append(sum(I_sum2))

# print(ans)
if(len(ans) == 0):
    print('-1')
else:
    print(int(min(ans)))
Buggy python submission (verdict: Time Limit Exceeded):
k = int(input())

import math 
from functools import reduce

sum = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        for c in range(1, k+1):
            sum += reduce(math.gcd, (a, b, c))

print(sum)

Fixed submission:
k = int(input())
 
import math
total = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        gcd2 = math.gcd(a, b)
        for c in range(1, k+1):
            total += math.gcd(gcd2, c)
print(total)
Buggy python submission (verdict: Runtime Error):
N, A, B = map(int, input().split())
ball = ""

while len(ball) < N:
  ball += "b" * A
  ball += "r" * B

ball_n = ball[:N]
print(ball_n.count("b"))

Fixed submission:
N, A, B = map(int, input().split())
stck = N // (A + B) * A
remn = N % (A + B)
stck += min(remn, A)
print(stck)
Buggy python submission (verdict: Time Limit Exceeded):
monsters, special = map(int, input().split())
HP = list(map(int, input().split()))

for i in range(special):
  HP.remove(max(HP))
  if HP == []:
    break

print(sum(HP))

Fixed submission:
import heapq
ceruleans, skills = map(int, input().split())
HP = list(map(lambda x: int(x) * (-1), input().split())) # OK! 次に進もうぜ
heapq.heapify(HP)

for i in range(skills):
  heapq.heappop(HP)

  if HP == []:
    break

print(-sum(HP))

Buggy python submission (verdict: Time Limit Exceeded):
monsters, special = map(int, input().split())
HP = list(map(int, input().split()))
HP.sort()

for i in range(special):
  HP.remove(HP[-1])
  if HP == []:
    break

print(sum(HP))

Fixed submission:
import heapq
ceruleans, skills = map(int, input().split())
HP = list(map(lambda x: int(x) * (-1), input().split())) # OK! 次に進もうぜ
heapq.heapify(HP)

for i in range(skills):
  heapq.heappop(HP)

  if HP == []:
    break

print(-sum(HP))
Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import sys
readline = sys.stdin.buffer.readline
s =int(readline().rstrip().decode())
def gcdsp(x,y,z):
    t =fractions.gcd(x,y)
    return fractions.gcd(t,z)
res = 0
for i in range(s):
    for j  in range(s):
        for k  in range(s):
            if i < j and j <= k:
                res += gcdsp(i+1, j+1, k+1)
res1 = int((s + 1)*s/2)
print(6*res+res1)


Fixed submission:
import math
import sys
readline = sys.stdin.buffer.readline
s =int(readline().rstrip().decode())
def gcdsp(x,y,z):
    t =math.gcd(x,y)
    return math.gcd(t,z)
res = 0
for i in range(s):
    for j  in range(s):
        for k  in range(s):
            if i < j and j <= k:
                res += gcdsp(i+1, j+1, k+1)
res1 = int((s + 1)*s/2)
print(6*res+res1)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
import sys
readline = sys.stdin.buffer.readline
s =int(readline().rstrip().decode())
def gcdsp(x,y,z):
    t =fractions.gcd(x,y)
    return fractions.gcd(t,z)
res = 0
for i in range(s):
    for j  in range(s):
        for k  in range(s):
            if i < j and j <= k:
                res += gcdsp(i+1, j+1, k+1)
res1 =0
for l in range(s):
    res1 += gcdsp(l+1,l+1,l+1)
print(6*res+res1)


Fixed submission:
import math
import sys
readline = sys.stdin.buffer.readline
s =int(readline().rstrip().decode())
def gcdsp(x,y,z):
    t =math.gcd(x,y)
    return math.gcd(t,z)
res = 0
for i in range(s):
    for j  in range(s):
        for k  in range(s):
            if i < j and j <= k:
                res += gcdsp(i+1, j+1, k+1)
res1 = int((s + 1)*s/2)
print(6*res+res1)
Buggy python submission (verdict: Runtime Error):
H=int(s[0])
W=int(s[1])
res =0
if H%2==0:
    res = int(H/2) * W
else:
    if W%2==0:
        #res = (int(H/2) + 1)* int(W/2) + (int(H/2))* int(W/2)  
        res = int(H/2) * W +  int(W/2)  
    else:
        res = int(H/2) * W + int(W/2)+1
print(res)

Fixed submission:
s=input().rstrip().split()
h=int(s[0])
w=int(s[1])
res =0
if h == 1 or w == 1:
  res = 1
elif h%2==0:
    res = (h/2) * w
else:
    if w%2==0:
        res = int(h/2) * w +  w/2  
    else:
        res = int(h/2) * w + int(w/2) + 1
print(int(res))
Buggy python submission (verdict: Runtime Error):
import numpy as np
s = input().split()
a=s[0]
b=s[1]
c=s[2]
if  np.sqrt(a) + np.sqrt(b) < np.sqrt(c):
    print('Yes')
else:
    print('No')
    

Fixed submission:
from decimal import Decimal
s = input().split()
a = Decimal(s[0])
b = Decimal(s[1])
c = Decimal(s[2])
if  4 * a * b < (c - a -b) **2 and c - a - b > 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
a = input()[-1
if a == '3':
  print('bon')
elif a == '0' or a=='1' or a=='6' or a=='8':
  print('pon')
else:
  print('hon')

Fixed submission:
a = input()[-1]
if a == '3':
  print('bon')
elif a == '0' or a=='1' or a=='6' or a=='8':
  print('pon')
else:
  print('hon')

Buggy python submission (verdict: Runtime Error):
a = input()[-1]
if a == 3:
  print('bon;)
elif a == 0 or a==1 or a==6 or a==8:
  print('pon')
else:
  print('hon')

Fixed submission:
a = input()[-1]
if a == '3':
  print('bon')
elif a == '0' or a=='1' or a=='6' or a=='8':
  print('pon')
else:
  print('hon')

Buggy python submission (verdict: Runtime Error):
a = input()[0]
if a == 3:
  print('bon;)
elif a == 0 or a==1 or a==6 or a==8:
  print('pon')
else:
  print('hon')

Fixed submission:
a = input()[-1]
if a == '3':
  print('bon')
elif a == '0' or a=='1' or a=='6' or a=='8':
  print('pon')
else:
  print('hon')
Buggy python submission (verdict: Runtime Error):
a, b, c, k = [int(i) for i in input().split()]

if k <= a and k - a <= b:
	print(k)
else
	print(a - (k - a - b))

Fixed submission:
a, b, c, k = [int(i) for i in input().split()]

if k <= a and k - a <= b:
	print(k)
else:
	print(a - (k - a - b))
Buggy python submission (verdict: Runtime Error):
from sys import stdin

n, m = list(map(int, input().split()))
h_n = list(map(int, input().split()))
a_b_m = stdin.readlines()

res = 0
omit_s = []
for i in range(1, n+1):
    count_omit = 0
    for k in range(len(omit_s)):
        if omit_s[k] == i:
            count_omit = 1
            break
    if count_omit == 0:
        count = 0
        count_higher = 0
        for j in range(m):
            a, b = [int(x) for x in a_b_m[j].rstrip().split()]
            if a == i:
                count = 1
                if h_n[b-1] >= h_n[a-1]:
                    count_higher = 1
                elif h_n[a-1] > h_n[b-1]:
                    ommit_s.append(b-1)
                    break
            elif b == i:
                count = 1
                if h_n[a-1] >= h_n[b-1]:
                    count_higher = 1
                    break
        if count == 1 and count_higher == 0:
            res += 1
        elif count == 0:
            res += 1
print(res)


Fixed submission:
s = str(input())

if s == 'ABC':
    print('ARC')
else:
    print('ABC')
Buggy python submission (verdict: Runtime Error):
from sys import stdin
from collections import Counter

lines = stdin.readlines()

n = int(lines[0].rstrip())
a = [int(x) for x in lines[1].rstrip().split()]

count = Counter(a)
c = {k:v for k,v in filter(lambda kv: kv[1]>1, count.items())}
res = []
for k in range(n):
    part_res = 0
    for i in c.keys():
        if not i == a[k]:
            quant = c[i]
        else:
            quant = c[i] - 1
        if quant > 1:
            part_res += int((quant * (quant - 1)) / 2)
    res.extend([part_res])

for j in range(len(res)):
    print(res[j])

Fixed submission:
from sys import stdin

n, m = [int(x) for x in stdin.readline().rstrip().split()]

even_only = 0
odd_only = 0

if n > 1:
    even_only = n * (n - 1) / 2
if m > 1:
    odd_only = m * (m - 1) / 2

result = int(even_only + odd_only)
print(result)

Buggy python submission (verdict: Runtime Error):
from sys import stdin
from collections import Counter

lines = stdin.readlines()

n = int(lines[0].rstrip())
a = [int(x) for x in lines[1].rstrip().split()]

c = Counter(a)

res = []
for k in range(n):
    part_res = 0
    for i in c.keys():
        if not i == a[k]:
            quant = c[i]
        else:
            quant = c[i] - 1
        if quant > 1:
            part_res += int((quant * (quant - 1)) / 2)
    res.extend([part_res])

for j in range(len(res)):
    print(res[j])

Fixed submission:
from sys import stdin

n, m = [int(x) for x in stdin.readline().rstrip().split()]

even_only = 0
odd_only = 0

if n > 1:
    even_only = n * (n - 1) / 2
if m > 1:
    odd_only = m * (m - 1) / 2

result = int(even_only + odd_only)
print(result)
Buggy python submission (verdict: Runtime Error):
from sys import stdin

A, B = [int(x) for x in stdin.readline().rstrip().split()]

min_eight_ex_tax = float(A / 0.08)
max_eight_ex_tax = float((A + 1) / 0.08)
min_ten_ex_tax = int(B / 0.1)
max_ten_ex_tax = int((B + 1) / 0.1)

res = float(-1)
for x in range(min_ten_ex_tax, max_ten_ex_tax, 1):
    if min_eight_ex_tax <= x < max_eight_ex_tax:
        res = float(x)
        break
#print(min_eight_ex_tax, max_eight_ex_tax, min_ten_ex_tax, max_ten_ex_tax)
print(int(res))

Fixed submission:
from sys import stdin

s = stdin.readline().rstrip()

count = 0
if s[0] == 'A':
    if s[1] == 'B':
        count += 1
if s[1] == 'A':
    if s[2] == 'B':
        count += 1
if s[0] == 'B':
    if s[1] == 'A':
        count += 1
if s[1] == 'B':
    if s[2] == 'A':
        count += 1
if count > 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
from sys import stdin

A, B = [int(x) for x in stdin.readline().rstrip().split()]

min_eight_ex_tax = float(A / 0.08)
max_eight_ex_tax = float((A + 1) / 0.08)
min_ten_ex_tax = float(B / 0.1)
max_ten_ex_tax = float((B + 1) / 0.1)

res = float(-1)
for x in range(min_ten_ex_tax, max_ten_ex_tax, 1):
    if min_eight_ex_tax <= x < max_eight_ex_tax:
        res = float(x)
        break
#print(min_eight_ex_tax, max_eight_ex_tax, min_ten_ex_tax, max_ten_ex_tax)
print(int(res))

Fixed submission:
from sys import stdin

A, B = [int(x) for x in stdin.readline().rstrip().split()]

min_eight_ex_tax = float(A / 0.08)
max_eight_ex_tax = float((A + 1) / 0.08)
min_ten_ex_tax = int(B / 0.1)
max_ten_ex_tax = int((B + 1) / 0.1)

res = float(-1)
for x in range(min_ten_ex_tax, max_ten_ex_tax, 1):
    if min_eight_ex_tax <= x < max_eight_ex_tax:
        res = float(x)
        break
#print(min_eight_ex_tax, max_eight_ex_tax, min_ten_ex_tax, max_ten_ex_tax)
print(int(res))
Buggy python submission (verdict: Runtime Error):
from sys import stdin

lines = stdin.readlines()

n = int(lines[0].rstrip())
s = str(lines[1].rstrip())

counter = 0
for i in range(n-2):
if s[i] == 'A':
    if s[i+1] == 'B':
        if [i+2] == 'C':
            counter += 1
print(counter)

Fixed submission:
from sys import stdin

lines = stdin.readlines()

n = int(lines[0].rstrip())
s = str(lines[1].rstrip())

counter = 0
for i in range(n-2):
    if s[i] == 'A':
        if s[i+1] == 'B':
            if s[i+2] == 'C':
                counter += 1
print(counter)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))
for i in range(N):
    print(A.count(i+1))

Fixed submission:
import collections
N = int(input())
A = list(map(int, input().split()))

c = collections.Counter(A)

for i in range(N):
    print(c[i+1])

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

for i in range(N):
    print(A.count(i+1))

Fixed submission:
import collections
N = int(input())
A = list(map(int, input().split()))

c = collections.Counter(A)

for i in range(N):
    print(c[i+1])
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
ans = 0
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1, K+1):
            ans += gcd(i,j,k)
print(ans)

Fixed submission:
K = int(input())
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)
ans = 0
for i in range(1,K+1):
    for j in range(i,K+1):
        for k in range(j, K+1):
            if (i == j and j == k):
                ans += i
            elif (i == j or j == k):
                ans += math.gcd(i, k)*3
            else:
                ans += gcd(i, j, k)*6
print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
A =list(map(int,input()))
A.sort()
for i in range(N-1):
    if A[i] == A[i+1]:
        print('NO')
        exit()
print('YES')
    

Fixed submission:
N = int(input())
A =list(map(int,input().split()))
A.sort()
for i in range(N-1):
    if A[i] == A[i+1]:
        print('NO')
        exit()
print('YES')
Buggy python submission (verdict: Runtime Error):
import collections
 
N=int(input())
D=list(map(int,input().split()))
 
c=collections.Counter(D)
 
max_D=max(D)
ans=1
previous_leaf=1
 
if D[0]!=0:
    ans=0
elif c[0]!=1:
    ans=0
else:
    for i in range(1,max_D+1):
        ans*=(previous_leaf**c[i])
        ans%=998244353
        previous_leaf=c[i]
 
print(ans)
import collections

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

c=collections.Counter(D)

max_D=max(D)
ans=1
previous_leaf=1

if D[0]!=0:
    ans=0
elif c[0]!=1:
    ans=0
else:
    for i in range(1,max_D+1):
        ans*=(previous_leaf**c[i])
        ans%=998244353
        previous_leaf=c[i]

print(ans)


Fixed submission:
import collections
 
N=int(input())
D=list(map(int,input().split()))
 
c=collections.Counter(D)
 
max_D=max(D)
ans=1
previous_leaf=1
 
if D[0]!=0:
    ans=0
elif c[0]!=1:
    ans=0
else:
    for i in range(1,max_D+1):
        ans*=(previous_leaf**c[i])
        ans%=998244353
        previous_leaf=c[i]
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import time
import random
import sys
input=sys.stdin.readline
#N=100000
N=int(input())
D=np.array(list(map(int,input().split())))
#D=np.concatenate([np.array([0]),np.array([random.randint(1,1000) for _ in range(99999)])])

#print(np.count_nonzero(D==0))
if D[0]!=0 or np.count_nonzero(D==0)!=1:
    print(0)
    exit()

k=max(D)


ans=1
past=1
for i in range(1,k+1):
    n=np.count_nonzero(D==i)
    if n==0:
        print(0)
        #ptime=time.time()-start
        #print(ptime)
        exit()
    ans*=past**n
    ans%=998244353
    past=n

print(ans)
#ptime=time.time()-start
#print(ptime)

Fixed submission:
import collections
 
N=int(input())
D=list(map(int,input().split()))
 
c=collections.Counter(D)
 
max_D=max(D)
ans=1
previous_leaf=1
 
if D[0]!=0:
    ans=0
elif c[0]!=1:
    ans=0
else:
    for i in range(1,max_D+1):
        ans*=(previous_leaf**c[i])
        ans%=998244353
        previous_leaf=c[i]
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
import time
import random
start = time.time()
#N=100000
N=int(input())
D=np.array(list(map(int,input().split())))
#D=np.concatenate([np.array([0]),np.array([random.randint(1,1000) for _ in range(99999)])])

#print(np.count_nonzero(D==0))
if D[0]!=0 or np.count_nonzero(D==0)!=1:
    print(0)
    exit()

k=max(D)


ans=1
past=1
for i in range(1,k+1):
    n=np.count_nonzero(D==i)
    if n==0:
        print(0)
        #ptime=time.time()-start
        #print(ptime)
        exit()
    ans*=past**n
    ans%=998244353
    past=n

print(ans)
#ptime=time.time()-start
#print(ptime)

Fixed submission:
import collections
 
N=int(input())
D=list(map(int,input().split()))
 
c=collections.Counter(D)
 
max_D=max(D)
ans=1
previous_leaf=1
 
if D[0]!=0:
    ans=0
elif c[0]!=1:
    ans=0
else:
    for i in range(1,max_D+1):
        ans*=(previous_leaf**c[i])
        ans%=998244353
        previous_leaf=c[i]
 
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b,x=map(int,input().split())
import math
rec=a*a*b/2
if x<=rec:
    c=x*2/a/b

    print(math.degrees(math.atan(b/c)))
else:
    x=a*a*b-x
    c=x*2/a/b
    print(90-math.degrees(math.atan(b/c)))


Fixed submission:
a,b,x=map(int,input().split())
import math
rec=a*a*b/2
if x==a*a*b:
    print(0)
    exit()
if x<=rec:
    c=x*2/a/b

    print(math.degrees(math.atan(b/c)))
else:
    x=a*a*b-x
    c=x*2/a/a
    print(90-math.degrees(math.atan(a/c)))
Buggy python submission (verdict: Runtime Error):
import math
A,B,C,D=map(int,input().split())

if A%C==0:
    x=B//C-A//C+1
else:
    x=B//C-A//C
if A%D==0:
    y=B//D-A//D+1
else:
    y=B//D-A//D
E=C*D/math.gcd(C,D)
if A%E==0:
    z=B//E-A//E+1
else:
    z=B//E-A//E
print(round(B-A+1-(x+y-z)))


Fixed submission:
def g(m,n):
    x=max(m,n)
    y=min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z
from decimal import Decimal
A,B,C,D=map(lambda x:Decimal(int(x)),input().split())



if A%C==0:
    x=B//C-A//C+1
else:
    x=B//C-A//C
if A%D==0:
    y=B//D-A//D+1
else:
    y=B//D-A//D
E=Decimal(C*D//g(C,D))
if A%E==0:
    z=B//E-A//E+1
else:
    z=B//E-A//E
print(B-A+1-(x+y-z))