Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p04030 (python)

Fixed submission:
s = input()
ans = ""
for i in s:
  if i == "B":
    if len(ans) > 0:
      ans = ans[:-1]
  else:
    ans = ans + i
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
ans = ""
for i in s
  if i == "B":
    if len(ans) > 0:
      ans = ans[:-1]
    else:
      ans = ans
  else:
    ans = ans + i
print(ans)

Buggy submission (verdict: Runtime Error):
s = input()
ans = ""
for i in s
  if i == "B":
    if len(ans) > 0:
      ans = ans[:-1]
    else:
      ans = ans
  else:
    ans = ans + c
print(ans)

Buggy submission (verdict: Runtime Error):
s = str(input())
ans = ""
n = len(s)
for i in range(n)
  if s[i] = "B":
    if ans == "":
      ans = ans + ""
    else:
      ans = ans[:-1]
  else:
    ans = ans + s[i]
Problem p04043 (python)

Fixed submission:
n = list(map (int, input().split()))
if n.count(int (5)) == 2 and n.count(int (7)) == 1:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
n = list(map(int,input().split()))
 if n.count(int (5)) == 2 and n.count(int (7)) == 1:
    print("YES")
  else:
    print("NO")

Buggy submission (verdict: Runtime Error):
n = list(map(int,input().split()))
 if n.count(int 5) == 2 and n.count(int 7) == 1:
    print("YES")
  else:
    print("NO")

Buggy submission (verdict: Runtime Error):
n = list(map(int,input().split))
if n.count(5) = 2 and n.count(7) = 1:
  print("YES")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
if A == 5:
  if B == 5:
    if C == 7:
      print(YES)
    else:
      print(NO)
  else if B == 7:
    if C == 5:
      print(YES)
    else:
      print(NO)
  else:
    print(NO)
else if A == 7:
  if B == 5 and C == 5:
    print(YES)
else:
  print(NO)
Problem p04044 (python)

Fixed submission:
n,l = map(int,input().split())
words = [input() for i in range(n)]
word = sorted(words)
print("".join(word))

Buggy submission (verdict: Runtime Error):
n,l = map(int,input().split())
words = [input() for i in range(n)]
words = words.sort()
print("".join(words))
Problem p03719 (python)

Fixed submission:
# -*- coding: utf-8 -*-
a,b,c = list(map(int,input().split()))
if a <= c <=b :
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
a,b,c=map(int,input().split())
if a<= c and b=>c:
    print("Yes")
else:
    print("No")
Problem p03943 (python)

Fixed submission:
a=list(map(int,input().split()))
a.sort()
if (a[2] == a[0]+a[1]):
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
x,y,n=list(map(int,input().split()))
xx=x
yy=y
S=[]
a1=0
b1=0
for _ in range(n):
    S.append(list(map(int,input().split())))
for a in S :
    if a[2]==1:
        a1 = max(a1,a[0])
    elif a[2]==2:
        xx = min(xx,a[0])
    elif a[2]==3:
        b1 = max(b1,a[1])
    elif a[2]==4:
        yy = min(yy,a[1])

if(xx-a1)*(yy-b1)<0 or xx< 0 <yy or xx> 0 >yy:
  print((xx-a1)*(yy-b1) if xx<a1 and yy<b1 else 0)
Problem p02606 (python)

Fixed submission:
L, R, d = map(int, input().split())
count = 0

for i in range(L,R+1):
    if i%d == 0:
        count+=1

print(count)

Buggy submission (verdict: Runtime Error):
L, R, d = map(int, input().split())
count = 0

for i in range(L,R):
　if i%d == 0:
     count++

print(count)
Problem p02741 (python)

Fixed submission:
lis1 = [0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())

print(lis1[k])

Buggy submission (verdict: Runtime Error):
lis = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
 
k = int(input())
 
print(lis[k])

Buggy submission (verdict: Runtime Error):
lis = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

k = int(input())

print(lis[k+1])
Problem p02802 (python)

Fixed submission:
n, m = map(int,input().split())

ac = 0
wac = 0
count = [0 for x in range(n+1)]

for i in range(m):
  a , b = input().split()
  c = int(a)
  if count[c] >= 0:
    if b == "AC":
      ac += 1
      wac += count[c]
      count[c] = -1
    else:
      count[c] += 1

print(ac, wac)

Buggy submission (verdict: Runtime Error):
n, m = map(int,input().split())

aclist = []
ac = 0
wac = 0
count = [0 for x in range(n+1)]

for i in range(m):
  a , b = input().split()
  int(a)
  if n >= 0:
    if n == "AC":
      ac += 1
      wac += count[a]
      count[a] = -1
    else:
      count[a] += 1

print(ac, wac)
Problem p02818 (python)

Fixed submission:
a,b,k = map(int,input().split())
ans1 = a-k
if ans1 <= 0:
    ans2 = b - abs(ans1)
    if ans2 < 0:
        ans2 = 0
    ans1 = 0
    print(ans1, ans2)
else:
    print(ans1, b)

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
ans1 = a-k
if ans1 <= 0:
    ans2 = b - abs(ans1)
    if ans2 < 0:
        ans2 = 0
    ans1 = 0
    print(ans1, ans2)
else:
    print(ans1, ans2)

Buggy submission (verdict: Runtime Error):
a,b,k = map(int,input().split())
ans1 = a-k
if ans1 <= 0:
    ans2 = b - abs(ans1)
    if ans2 <= 0:
        ans2 = 0
    ans1 = 0
    print(ans1, ans2)
else:
    print(ans1, ans2)
Problem p03293 (python)

Fixed submission:
s = str(input())
n = str(input())
ans = 0
for i in range(len(s)):
    s = s[1:] + s[0]
    if s == n:
        ans = 1
        break

if ans == 1:
    print("Yes")
else:
    print("No")

Buggy submission (verdict: Runtime Error):
s = str(input())
n = str(input())
ans = 0
for i in range(len(s)):
    s = s[1:] + s[0]
    if s == n:
        ans = 1
        break-

if ans == 1:
    print("Yes")
else:
    print("No")
Problem p03860 (python)

Fixed submission:
a = list(map(str,input().split()))

print("A{}C".format(a[1][0]))

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))
b = a[1]
c = b[0]

print("A{}C".format(c))

Buggy submission (verdict: Runtime Error):
a = list(map(int,input().split()))

print("A{}C".format(a[1]))
Problem p04029 (python)

Fixed submission:
a = int(input())
ans = 0
 
for i in range(a):
  i += 1
  ans = ans + i
  
print(ans)

Buggy submission (verdict: Runtime Error):
a = int(inpit())
ans = 0

if i in range(a):
  i += 1
  ans = ans + i
  
print(ans)
Problem p04043 (python)

Fixed submission:
a = list(map(int,input().split()))

if a.count(5) == 2:
  if a.count(7) == 1:
    print("YES")
  else:
    print("NO")
else:
  print("NO")

Buggy submission (verdict: Runtime Error):
a , b = map(int,input().split())
list = []
papa = ""
for i in range(b):
  list.append(input()) 
c = sorted(list)
for x in c:
  papa += x
print(papa)
Problem p04044 (python)

Fixed submission:
a , b = map(int,input().split())
c_list = sorted([input() for i in range(a)])
print("".join(c_list))

Buggy submission (verdict: Runtime Error):
a , b = map(int,input().split())
c_list = [input() for i in range(a)]
c.sort()
print("".join(c))

Buggy submission (verdict: Runtime Error):
a , b = map(int,input().split())
c_list = [input() for i in range(a)]
c.sort()
print("".join(c))

Buggy submission (verdict: Runtime Error):
a , b = map(int,input().split())
list = []
papa = ""
for i in range(b):
  list.append(input()) 
c = sorted(list)
for x in c:
  papa += x
print(papa)

Buggy submission (verdict: Runtime Error):
a , b = map(int,input().split())
 
 
list = []
papa = ""
 
for i in range(b):
  list.append(input())
  
list.sort()
for x in list:
  papa += x
print(papa)

Buggy submission (verdict: Runtime Error):
a , b = map(int,input().split())


list = []

for i in range(b):
  list.append(input())
  
list.sort()
print(join(list))
Problem p02684 (python)

Fixed submission:
n, k = map(int, input().split())
a = [0] + list(map(int, input().split()))

journey = [1]

for i in range(2*n + 100):
    nxt = a[journey[-1]]
    journey.append(nxt)
    
if k < n + 1:
    print(journey[k])
    exit()

loop_end = n

loop_start = n-1

while(journey[loop_start] != journey[loop_end]):
    loop_start -= 1

period = loop_end - loop_start

k %= period
while k<= n:
    k += period

print(journey[k])

Buggy submission (verdict: Runtime Error):
temp = input()
temp = temp.split()
town_num = int(temp[0])
move = int(temp[1])

town = input()
town = town.split()
town = [int(s) for s in town]
data = [0] * 1000

position = 1

if move < 1000:
    for i in range(move):
      position = town[position-1]

else:
    for i in range(town_num):
        data[i] = town[position-1]
        position = town[position-1]
        if data[i] == data[4] and i > 4:
            count = i
            break
    cycle = count - 4
    try:
        period = (move-4)%cycle
        position = data[period+4]
        position = town[position-1]-1
    except ZeroDivisionError:
        a = 1

print(position)

Buggy submission (verdict: Runtime Error):
temp = input()
temp = temp.split()
town_num = int(temp[0])
move = int(temp[1])

town = input()
town = town.split()
town = [int(s) for s in town]
data = [0] * 1000

position = 1

if move < 1000:
    for i in range(move):
      position = town[position-1]

else:
    for i in range(town_num):
        data[i] = town[position-1]
        position = town[position-1]
        if data[i] == data[4] and i > 4:
            count = i
            break
    cycle = count - 4
    try:
        period = (move-4)%cycle
        position = data[period+4]
        position = town[position-1]-1
    except ZeroDivisionError:
        a = 1


print(position)

Buggy submission (verdict: Runtime Error):
temp = input()
temp = temp.split()
town_num = int(temp[0])
move = int(temp[1])

town = input()
town = town.split()
town = [int(s) for s in town]
data = [0] * 1000

position = 1

if move < 1000:
    for i in range(move):
      position = town[position-1]

else:
    for i in range(town_num):
        data[i] = town[position-1]
        position = town[position-1]
        if data[i] == data[4] and i > 4:
            count = i
            break
    cycle = count - 4
    try:
        period = (move-4)%cycle
        position = data[period+4]
        position = town[position-1]-1
    except ZeroDivisionError:
        a = 1


print(position)
Problem p02687 (python)

Fixed submission:
a = input()

if a == 'ABC':
  print('ARC')
else:
  print('ABC')

Buggy submission (verdict: Runtime Error):
N = int(input())

height = input()
height = height.split()
height = [int(s) for s in height]

count = 0

for i in range(N):
  for j in range(i+1, N):
    if j-i == height[i] + height[j]:
      count += 1

print(count)

Buggy submission (verdict: Runtime Error):
X = int(input())
 
flag = 0
A = 0
B = 0
 
for i in range(0, 100000):
  for j in range(0, 100000):
    if i**5 - j**5 == X:
      A = i
      B = j
      break
    elif i**5 + j**5 == X:
      A = i
      B = j
      break
    elif -i**5 - j**5 == X:
      A = -i
      B = j
      break
print(str(A) + ' ' + str(B))

Buggy submission (verdict: Runtime Error):
X = int(input())
 
flag = 0
A = 0
B = 0
 
for i in range(0, 100):
  for j in range(0, 100):
    if i**5 - j**5 == X:
      A = i
      B = j
      break
    elif i**5 + j**5 == X:
      A = i
      B = j
      break
    elif -i**5 - j**5 == X:
      A = -i
      B = j
      break
print(str(A) + ' ' + str(B))
Problem p02901 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# if x < y:
#     z = x
# elif True:
#     z = y
# else:
#     z = 100
import sys,os,math
from collections import Counter, defaultdict
import bisect
from sys import stdin, stdout
from itertools import repeat


# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())

def main():
    n, m = map(int, raw_input().split())
    bf, af = [10000000 for i in range(1<<n)], [10000000 for i in range(1<<n)]
    bf[0] = 0
    for i in range(m):
        a, b = map(int, raw_input().split())
        ad = 0
        for st in map(int, raw_input().split()):
            ad |= 1<<(st-1)
        for st in range(1<<n):
            af[st|ad] = min(bf[st|ad], bf[st]+a, af[st|ad])
        for st in range(1<<n):
            af[st] = min(af[st], bf[st])
        bf, af = af, bf
    if bf[(1<<n)-1] == 10000000:
        print -1
    else:
        print bf[(1<<n)-1]



main()

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# if x < y:
#     z = x
# elif True:
#     z = y
# else:
#     z = 100
import sys,os,math
from collections import Counter, defaultdict
import bisect
from sys import stdin, stdout
from itertools import repeat

sys.stdin = open('input')
# n, k = map(int, raw_input().split())
# da = map(int, raw_input().split())
# db = map(int, raw_input().split())

def main():
    n, m = map(int, raw_input().split())
    bf, af = [10000000 for i in range(1<<n)], [10000000 for i in range(1<<n)]
    bf[0] = 0
    for i in range(m):
        a, b = map(int, raw_input().split())
        ad = 0
        for st in map(int, raw_input().split()):
            ad |= 1<<(st-1)

        for st in range(1<<n):
            af[st|ad] = min(bf[st|ad], bf[st]+a, af[st|ad])
        # print af
        bf, af = af, bf
    if bf[(1<<n)-1] == 10000000:
        print -1
    else:
        print bf[(1<<n)-1]



main()
Problem p02784 (python)

Fixed submission:
val = input()
h, n = [int(x) for x in val.split()]
val = input()
a = [int(x) for x in val.split()]
 
sum = sum(a)
if h - sum <= 0:
  print("Yes")
else:
  print("No")

Buggy submission (verdict: Runtime Error):
val = input()
h, n = [int(x) for x in val.split()]
val = input()
a = [int(x) for x in val.split()]

sum = a.sum()
if h - sum <= 0:
  print("Yes")
else:
  print("No")
Problem p02613 (python)

Fixed submission:
import math
import collections


def main():
  N = int(input())
  S = [input() for _ in range(N)]
  
  A = collections.Counter(S)
  
  
  print('AC x ' + str(A['AC']))
  print('WA x ' + str(A['WA']))
  print('TLE x ' + str(A['TLE']))
  print('RE x ' + str(A['RE']))
  
  
  
main()

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


def main():
  N = int(input())
  S = [int(input()) for _ in range(N)]
  
  A = collections.Counter(S)
  
  print('AC × ' + A['AC'])
  print('WA × ' + A['WA'])
  print('TLE × ' + A['TLE'])
  print('RE × ' + A['RE'])
  
  
  
main()
Problem p02639 (python)

Fixed submission:
a = list(map(int, input().split()))

if a[0] == 0:
  print(1)
elif a[1] == 0:
  print(2)
elif a[2] == 0:
  print(3)
elif a[3] == 0:
  print(4)
else:
  print(5)

Buggy submission (verdict: Runtime Error):
a = input()
x = int(a)

for i, k in x:
  if k == 0:
    print(i)
    break;
Problem p02657 (python)

Fixed submission:
a, b = map(int, input().split())

print(a * b)

Buggy submission (verdict: Runtime Error):
x = int(input())
y = int(input())

print(x*y)
Problem p02658 (python)

Fixed submission:
def main():
    N = int(input())
    A = list(map(int, input().split()))
 
    if 0 in A:
        print(0)
        return
    
    ans = 1
 
    for i in A:
        ans *= i
      
        if ans > 10 ** 18:
            print(-1)
            return 
      
    print(ans)  

main()

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
 
ans = 1
 
for i in A:
  ans *= i
  
  if ans > 10 ** 18:
  print(-1)
  return 
  
 
  
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
 
ans = 1
 
for i in N:
  ans *= A[i]
  
  if ans > 10 ** 18:
  print(-1)
  return 
  

  
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
 
ans = 1

for i in N:
  ans *= A[i]
  
if ans > 10 ** 18:
  ans = -1
  
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
 
for i in N:
  ans *= A[i]
  
if ans > 10**18:
  ans = -1
  
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

for i in N:
  ans *= A[i]
  
print(ans)
Problem p02675 (python)

Fixed submission:
def main():
  a = int(input())
  x = a % 10
  
  if x in (2,4,5,7,9):
    print('hon')
    return
  elif x in (0,6,1,8):
    print('pon')
    return
  else:
    print('bon')
  
main()

Buggy submission (verdict: Runtime Error):
def main():
  a = int(input())
  
  i = a % 10
  
  if i == 2 or 4 or 5 or 7 or 9:
    print('hon')
    return
  elif i == 0 or 1 or 6 or 8:
  	print('pon')
    return
  else:
    print('bon')
main()
Problem p02694 (python)

Fixed submission:
def main():
  x = int(input())
  
  total = 100
  year = 0
  
  while total < x:
    #total = math.floor(total * 1.01)
    total += total // 100
    year += 1
  
  print(year)
  
  
  
main()

Buggy submission (verdict: Runtime Error):
def main():
  x = int(input())
  
  total = 100
  year = 0
  
  while total < x:
    total = math.floor(total * 1.01)
    year += 1
  
  print(year)
  
  
  
main()
Problem p02812 (python)

Fixed submission:
def main():
  N = int(input())
  S = input()
  
  cnt = 0
  
  for i in range(N-2):
    if S[i] == 'A':
      if S[i+1] == 'B':
        if S[i+2] == 'C':
          cnt += 1
  print(cnt)
  
  
main()

Buggy submission (verdict: Runtime Error):
def main():
  N = int(input())
  S = input()
  
  cnt = 0
  
  for i in range(N):
    if S[i] == 'A':
      if S[i+1] == 'B':
        if S[i+2] == 'C':
          cnt += 1
  print(cnt)
  
  
main()
Problem p02606 (python)

Fixed submission:
L, R, d = [int(x) for x in input().split()]
compteur = 0

for i in range(L, R+1):
  if i%d == 0:
    compteur += 1
   
print(compteur)

Buggy submission (verdict: Runtime Error):
L, R, d = [int(x) for x in input().split()]
compteur = 0

for i in range(L, R+1):
  if i%d == 0:
    k += 1
Problem p02658 (python)

Fixed submission:
N = int(input())
liste = input().split()
number = [int(x) for x in liste]
total = 1
i = 0
if 0 in number:
    total = 0
else:
    while i < N:
            total *= number[i]
            i = i + 1
            if total > 10**18:
                total = -1
                break
print(total)

Buggy submission (verdict: Runtime Error):
N = int(input())
numbers = [int(x) for x in input().split()]

if any [x == 0 for x in numbers]:
  print(0)
else:
  t = numbers [0]
  for el in numbers:
  	while total < 10**18:
    	t *= el 
  	if t < 10**18:
    	print(t)
    else:
      print(-1)

Buggy submission (verdict: Runtime Error):
i = 0
if 0 in number:
    total = 0
else:
    while i < N:
            total *= number[i]
            i = i + 1
            if total > 10**18:
                total = -1
                break
print(total)
Problem p02663 (python)

Fixed submission:
chr = input().split()
a = (int(chr[2]) - int(chr[0]))*60 + (int(chr[3]) - int(chr[1])) - int(chr[-1])
print(a)

Buggy submission (verdict: Runtime Error):
chr = input().split(" 0 ")
a = (int(chr[1])-int(chr[0]))*60 - int(chr[-1])
print(a)

Buggy submission (verdict: Runtime Error):
chr = input().split(" 0 ")
print(chr)
a = (int(chr[1])-int(chr[0]))*60 - int(chr[-1])
print(a)

Buggy submission (verdict: Runtime Error):
chr = input().split(" 0 ")
print(chr)
a = (int(chr[1])-int(chr[0]))*60 - int(chr[-1])
print(a)
Problem p02850 (python)

Fixed submission:
n = int(input())
G = [[] for i in range(n)]
root = 0
color_num = 0

for i in range(n - 1):
  a, b = map(int, input().split())
  G[a - 1].append((b - 1, i))
  G[b - 1].append((a - 1, i))
  if color_num < len(G[a - 1]):
    root = a - 1
    color_num = len(G[a - 1])
  elif color_num < len(G[b - 1]):
    root = b - 1
    color_num = len(G[b - 1])

# print(G)
# [[1], [0, 2, 3, 4], [1], [1, 6], [1, 5], [4, 7], [3], [5]]
# print(root) # 最も多い色を持つノードの番号
print(color_num)  # 必要な最小色数
queue = [(root, -1)]
checked = set()
answer = [-1] * (n - 1)

while len(queue) > 0:
  node, c = queue.pop(0)
  color = 1
  for node2, index in G[node]:
    if node2 not in checked:
      if color == c:
        color = c + 1
      answer[index] = color
      color += 1
      queue.append((node2, answer[index]))
  checked.add(node)
print('\n'.join(map(str, answer)))

Buggy submission (verdict: Runtime Error):
n = int(input())
G = [[] for i in range(n)]
root = 0
color_num = 0
keys = []

def get_key(n1, n2):
  if n1 > n2:
    return str(n2) + '-' + str(n1)
  return str(n1) + '-' + str(n2)

for _ in range(n - 1):
  a, b = map(int, input().split())
  keys.append(get_key(a - 1, b - 1))
  G[a - 1].append(b - 1)
  G[b - 1].append(a - 1)
  if len(G[a - 1]) > color_num:
    root = a - 1
    color_num = len(G[a - 1])
  elif len(G[b - 1]) > color_num:
    root = b - 1
    color_num = len(G[b - 1])

# print(root) # 最も多い色を持つノードの番号
print(color_num) # 必要な最小色数
queue = [root]
checked = set()
result = {}

while len(queue) > 0:
  node = queue.pop(0)
  # print(node + 1)
  ks = list(range(color_num))
  for node2 in G[node]:
    key = get_key(node, node2)
    if key in result:
      ks.pop(result[key])
    if node2 not in checked:
      result[key] = ks.pop(0)
      queue.append(node2)
  checked.add(node)

for k in keys:
  print(result[k] + 1)
Problem p02866 (python)

Fixed submission:
import sys

def main():
    N = int(input())
    D = list(map(lambda i: int(i), input().split(' ')))
    # N = 100000
    # D = [0]
    # for i in range(1, N):
    #     D.append(i)

    if D[0] != 0:
        print(0)
        sys.exit()

    ary = [0] * N
    for d in D:
        ary[d] = ary[d] + 1

    # 続いてなかったらNG
    zero = False
    for i in range(len(ary)):
        if ary[i] != 0 and zero is True:
            print(0)
            sys.exit()
        if ary[i] == 0 and zero is False:
            zero = True

    # 距離0は頂点1だけ
    if ary[0] != 1:
        print(0)
        sys.exit()

    answer = 1
    for i in range(1, len(ary)):
        for j in range(ary[i]):
            answer = (answer * ary[i - 1]) % 998244353
    print(answer)

main()

Buggy submission (verdict: Runtime Error):
import sys

def main():
    N = int(input())
    D = map(lambda i: int(i), input().split(' '))
    answer = 1
    ary = [0] * (N - 1)

    for d in D:
        ary[d] = ary[d] + 1

    # 続いてなかったらNG
    zero = False
    for i in range(len(ary)):
        if ary[i] != 0 and zero is True:
            print(0)
            sys.exit()
        if ary[i] == 0 and zero is False:
            zero = True
            
    for i in range(len(ary)):
        if i == 0:
            if ary[i] != 1:
                print(0)
                sys.exit()
        else:
            answer = (answer * (ary[i - 1] ** ary[i])) % 998244353
    print(answer)

main()

Buggy submission (verdict: Runtime Error):
import sys

def main():
    N = int(input())
    D = map(lambda i: int(i), input().split(' '))
    maximum = 0
    ary = [0] * (N - 1)
    for d in D:
        ary[d] = ary[d] + 1
        if maximum < d:
            maximum = d
    answer = 1
    for i in range(maximum + 1):
        if i == 0:
            if ary[i] != 1:
                print(0)
                sys.exit()
        elif ary[i] == 0:
            print(0)
            sys.exit()
        else:
            answer = (answer * (ary[i - 1] ** ary[i])) % 998244353
    print(answer)

main()

Buggy submission (verdict: Runtime Error):
import sys

def main():
    N = int(input())
    D = map(lambda i: int(i), input().split(' '))
    maximum = 0
    ary = [0] * (N - 1)
    for d in D:
        ary[d] = ary[d] + 1
        if maximum < d:
            maximum = d
    answer = 1
    for i in range(maximum + 1):
        if i == 0:
            if ary[i] != 1:
                print(0)
                sys.exit()
        elif ary[i] == 0:
            print(0)
            sys.exit()
        else:
            answer = (answer * (ary[i - 1] ** ary[i])) // 998244353
    print(answer)

main()