ZhenlongDai/ACPR huggingface dataset:
Problem: p02694
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X = int(input())
money = 100
count = 0
while money <= X:
    money = int(money*1.01) 
    count +=1
print(count)

Failing test case input:
608

Expected output:
230


Actual output:
231


Fixed submission (verdict: Accepted):
X = int(input())
money = 100
count = 0
while money < X:
    money = int(money*1.01) 
    count +=1
print(count)

Problem: p02694
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def main():
    x = int(input())
    y = 100
    i = 0
    while y >= x:
        i += 1
        y *= 1.01
    print(i)
main()

Failing test case input:
858488

Expected output:
968


Actual output:
0


Fixed submission (verdict: Accepted):
import math

def main():
    x = int(input())
    y = 100
    i = 0
    while y < x:
        i += 1
        y *= 1.01
        y = math.floor(y)
    print(i)
main()

Problem: p02694
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X=int(input())
temp=100
an=0
while True:
  temp=temp*1.01
  an+=1
  
  if temp>X:
    break
print(an-1)
  

Failing test case input:
12990749

Expected output:
1241


Actual output:
1183


Fixed submission (verdict: Accepted):
X=int(input())
temp=100
an=0
while True:
  temp=int(temp*1.01)
  an+=1
  
  if temp>=X:
    break
print(an)

Problem: p02694
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
n = int(input())
poket = 100
count = 0

while poket <= n:
    poket += int(poket*0.01)
    count += 1

print(count)

Failing test case input:
608

Expected output:
230


Actual output:
231


Fixed submission (verdict: Accepted):
n = int(input())
poket = 100
count = 0

while True:
    poket += int(poket*0.01)
    count += 1
    if(poket>=n):
        break
    
print(count)

Problem: p02694
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X = int(input())
year = 0
total = 100

while total < X:
    total = round(total + 0.01 * total)
    year += 1
    
print(year)

Failing test case input:
1847527

Expected output:
1045


Actual output:
995


Fixed submission (verdict: Accepted):
X = int(input())
year = 0
total = 100

while total < X:
    total = total + int(0.01 * total)
    year += 1
    
print(year)

Problem: p02694
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x = int(input())
m = 100
count = 1
while x > m:
    m = m + m/100
    count += 1
print(count)

Failing test case input:
490166812

Expected output:
1606


Actual output:
1550


Fixed submission (verdict: Accepted):
x = int(input())
m = 100
count = 0
while x > m:
    r = int(m*0.01)
    m = m + r
    count += 1
print(count)

Problem: p02694
Buggy submission (Python (3.8.2), verdict: Wrong Answer):

x = int(input())
m = 100
for i in range(10**18):
    m *= 1.01
    if m >= x:
        print(i+1)
        break

Failing test case input:
29927702

Expected output:
1325


Actual output:
1268


Fixed submission (verdict: Accepted):

x = int(input())
m = 100
for i in range(10**18):
    m *= 1.01
    m = int(m)
    if m >= x:
        print(i+1)
        break
Problem: p02694
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
x=int(input())
trial=0
p=100
while p<x:
  trial+=1
  p=p*1.01
print(trial)


Failing test case input:
2659200

Expected output:
1081


Actual output:
1024


Fixed submission (verdict: Accepted):
import math

x=int(input())
trial=0
p=100
while p<x:
  trial+=1
  p=p*1.01
  p=math.floor(p)
print(trial)

Problem: p02694
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import math

X=int(input())
yen=100
for i in range(3760):
  yen=math.floor(yen*1.01)
  
  if yen>X:
    break
print(i+1)
  

Failing test case input:
1100010000000000000

Expected output:
3770


Actual output:
3760


Fixed submission (verdict: Accepted):
import math

X=int(input())
yen=int(100)
for i in range(3800):
  yen=int(math.floor(yen*1.01))
  
  if yen>=X:
    break
print(i+1)

Problem: p02694
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
X = int(input())
year = 0
deposit = 101
while deposit < X:
    deposit += int(str(deposit)[0: -2])
    year += 1
print(year)

Failing test case input:
394

Expected output:
182


Actual output:
181


Fixed submission (verdict: Accepted):
X = int(input())
year = 0
deposit = 100
while deposit < X:
    deposit += int(str(deposit)[0: -2])
    year += 1
print(year)

Problem: p02694
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
import sys

X = int(input())

A = 100
cnt = 0
while True:
  if A > X:
    print(cnt)
    sys.exit()
  A *= 1.01
  A = int(A)
  cnt += 1

Failing test case input:
608

Expected output:
230


Actual output:
231


Fixed submission (verdict: Accepted):
import sys

X = int(input())

A = 100
cnt = 0
while True:
  if A >= X:
    print(cnt)
    sys.exit()
  A *= 1.01
  A = int(A)
  cnt += 1

Problem: p02694
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
k=int(input())
start=100
i=0
while True:
    i+=1
    start*=1.01
    start=int(start)
    if start>k:
        break
print(i)

Failing test case input:
608

Expected output:
230


Actual output:
231


Fixed submission (verdict: Accepted):
k=int(input())
start=100
i=0
while True:
    i+=1
    start=start*1.01
    if start>k:
        break
    start=int(start)
print(i)
Problem: p03488
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import exit
from collections import defaultdict
import itertools



S = str(input())
x,y = [int(n) for n in input().split()]

dx = []
dy = []
X = True
tmp = 0

memox = set([0])
memoy = set([0])
S = [len(s) for s in S.split("T")]
dx = S[0::2]
dy = S[1::2]
x -= dx[0]
del dx[0]

def check(d):
    memo = set([0])
    for t in d:
        memo = {a+b for a,b in itertools.product(memo, [-t, t])}




print("Yes" if check(dx) and check(dy) else "No")


Failing test case input:
FTFFTFFF
4 2

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
from sys import exit
from collections import defaultdict
import itertools



S = str(input())
x,y = [int(n) for n in input().split()]

dx = []
dy = []
X = True
tmp = 0


S = [len(s) for s in S.split("T")]
dx = S[0::2]
dy = S[1::2]
x -= dx[0]
del dx[0]

def check(d, p):
    memo = set([0])
    for t in d:
        memo = {a+b for a,b in itertools.product(memo, [-t, t])}
    return (p in memo)


print("Yes" if check(dx,x) and check(dy,y) else "No")

Problem: p03488
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
order = list(map(len, input().split("T")))
x, y = map(int, input().split())
ans = "No"
lon = [order[i] for i in range(len(order)) if i % 2 == 0]
lat = [order[i] for i in range(len(order)) if i % 2 == 1]
x += lon[0]
lon = lon[1:]
def f(x, A):
  A.append(abs(x))
  A.sort(reverse=True)
  k = A[0]
  for p in A[1:]:
      if k > 0:
        k -= p
      else:
        k += p
  if k == 0:
    return True
  else:
    return False
  

if f(x, lon) == f(y, lat) == True:
  ans = "Yes"
  
print(ans)

Failing test case input:
FTFFTFFF
4 2

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
order = list(map(len, input().split("T")))
x, y = map(int, input().split())
ans = "No"
lon = [order[i] for i in range(len(order)) if i % 2 == 0]
lat = [order[i] for i in range(len(order)) if i % 2 == 1]
x -= lon[0]
lon = lon[1:]
def f(x, A):
  A.append(abs(x))
  A.sort(reverse=True)
  k = A[0]
  for p in A[1:]:
      if k > 0:
        k -= p
      else:
        k += p
  if k == 0:
    return True
  else:
    return False
  

if f(x, lon) == f(y, lat) == True:
  ans = "Yes"
  
print(ans)

Problem: p03488
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=list(map(len,input().split("T")))
x,y=map(int,input().split())
def f(t,w):
    m={(0,0):True}
    for i in range(len(t)):
        m[(i+1,w+t[i])]=True
        m[(i+1,w-t[i])]=True
    return (len(t),w) in m
print(["No","Yes"][f(s[2::2],x-s[0]) and f(s[1::2],y)])

Failing test case input:
FTFFTFFF
4 2

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
s=list(map(len,input().split("T")))
x,y=map(int,input().split())
def f(t,w):
    m=[{} for i in range(len(t)+1)]
    m[0][0]=1
    for i in range(len(t)):
        for z in m[i]:
            m[i+1][z+t[i]]=1
            m[i+1][z-t[i]]=1
    return w in m[len(t)]
print(["No","Yes"][f(s[2::2],x-s[0]) and f(s[1::2],y)])
Problem: p03488
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

s = input().split("T")
x, y = ([int(i) for i in input().split()])


movex = []
movey = []

for i, t in enumerate(s):
    if i % 2 == 0:
        movex.append(len(t))
    else:
        movey.append(len(t))


def t_dfs(move, target):
    move.sort()
    for dx in move:
        if target > 0:
            target -= dx
        else:
            target += dx

    return target == 0


if t_dfs(movex, x) and t_dfs(movey, y):
    print("YES")
else:
    print("No")


Failing test case input:
FTFFTFFF
4 2

Expected output:
Yes

Actual output:
YES


Fixed submission (verdict: Accepted):

s = input().split("T")
x, y = ([int(i) for i in input().split()])


movex = []
movey = []

for i, t in enumerate(s):
    if i % 2 == 0:
        movex.append(len(t))
    else:
        movey.append(len(t))




def t_dfs(move, target, is_x):
    if is_x:
        target -= move.pop(0)

    move.sort(reverse=True)

    for dx in move:
        if target > 0:
            target -= dx
        else:
            target += dx

    return target == 0


if t_dfs(movex, x, True) and t_dfs(movey, y, False):
    print("Yes")
else:
    print("No")

Problem: p03488
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
def isok(f,p):
  s=0
  if not f and p==0:return 1
  for i,j in enumerate(f):
    s+=j
    if s>=p:break
  else:return 0
  for j in f[i+1:]:
    if s>=p:s-=j
    else:s+=j
  return s==p
s=input()
x,y=map(int,input().split())
f=list(map(len,s.split('T')))
x-=f[0]
x,y=abs(x),abs(y)
xf=sorted(f[2::2])[::-1]
yf=sorted(f[1::2])[::-1]
print(['No','Yes'][isok(xf,x) and isok(yf,y)])
print(f)

Failing test case input:
FTFFTFFF
4 2

Expected output:
Yes

Actual output:
Yes
[1, 2, 3]


Fixed submission (verdict: Accepted):
def isok(f,p):
  s=0
  if not f and p==0:return 1
  for i,j in enumerate(f):
    s+=j
    if s>=p:break
  else:return 0
  for j in f[i+1:]:
    if s>=p:s-=j
    else:s+=j
  return s==p
s=input()
x,y=map(int,input().split())
f=list(map(len,s.split('T')))
x-=f[0]
x,y=abs(x),abs(y)
xf=sorted(f[2::2])[::-1]
yf=sorted(f[1::2])[::-1]
print(['No','Yes'][isok(xf,x) and isok(yf,y)])

Problem: p03488
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
s=input().split('T')
p=list(map(int,input().split()))
mv=[len(i) for i in s]
d=[[],[]]
for i in range(len(mv)):
    d[i&1].append(mv[i])
x=d[0].copy()
y=d[1].copy()
t=[x[0],0]
x.sort()
y.sort()
while x!=[]:
    if t[0]>p[0]:t[0]-=x.pop()
    else:t[0]+=x.pop()
while y!=[]:
    if t[1] > p[1]:
        t[1] -= y.pop()
    else:t[1] += y.pop()
print(['No','Yes'][p==t])

Failing test case input:
FTFFTFFF
4 2

Expected output:
Yes

Actual output:
No


Fixed submission (verdict: Accepted):
s=input().split('T')
p=list(map(int,input().split()))
mv=[len(i) for i in s]
d=[[],[]]
for i in range(len(mv)):
    d[i&1].append(mv[i])
x=d[0].copy()
y=d[1].copy()
t=[x.pop(0),0]
x.sort()
y.sort()
while x!=[]:
    if t[0]>p[0]:t[0]-=x.pop()
    else:t[0]+=x.pop()
while y!=[]:
    if t[1] > p[1]:t[1] -= y.pop()
    else:t[1] += y.pop()
print(['No','Yes'][p==t])
Problem: p03215
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(n):
  x=0
  for j in range(i,n):
    x+=a[j]
    b.append(x)
ans=0
l=len(b)
for i in range(40,0,-1):
  x=0
  s=2**i-1
  for j in range(l):
    if b[j]%s==0:
      b[j]
      x+=1
  if x>=k:ans+=s
print(s)

Failing test case input:
8 6
8 1 27 2 7 8 7 6

Expected output:
48


Actual output:
1


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(n):
  x=0
  for j in range(i,n):
    x+=a[j]
    b.append(x)
ans=0
l=len(b)
for i in range(40,-1,-1):
  x=0
  s=2**i
  for j in range(l):
    if b[j]&(ans+s)==ans+s:x+=1
  if x>=k:ans+=s
print(ans)

Problem: p03215
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int,input().split())
A = list(map(int,input().split()))
X = []
for l in range(N):
  r = l
  v = 0
  while r < N:
    v += A[r]
    X.append(v)
    r += 1
X.sort()
X=X[::-1]
ans = X[0]
for x in X[:K]:
  ans = (ans & x)
print(ans)


Failing test case input:
8 8
2 0 8 0 7 6 6 4

Expected output:
21


Actual output:
1


Fixed submission (verdict: Accepted):
N, K = map(int,input().split())
A = list(map(int,input().split()))
X = []
for l in range(N):
  r = l
  v = 0
  while r < N:
    v += A[r]
    X.append(v)
    r += 1
ans = 0
for i in range(60, -1, -1):
  Y = [ x for x in X if (x >> i & 1) == 1 ]
  if len(Y) >= K:
    ans += 1 << i
    X = Y
print(ans)

Problem: p03215
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N, K = map(int, input().split())
*A, = map(int, input().split())

L = []
for i in range(N):
    v = A[i]
    L.append(v)
    for j in range(i+1, N):
        v += A[j]
        L.append(v)
L.sort(reverse=1)
R = []
ans = 2**32-1
for i in range(K):
    ans &= L[i]
print(ans)

Failing test case input:
8 6
15 1 53 2 1 8 6 6

Expected output:
68


Actual output:
64


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
*A, = map(int, input().split())

L = []
for i in range(N):
    v = A[i]
    L.append(v)
    for j in range(i+1, N):
        v += A[j]
        L.append(v)
ans = 0
for i in range(64):
    b = 1 << (63-i)
    c = 0
    R = []
    for j in range(len(L)):
        if b & L[j]:
            R.append(L[j])
    if len(R) >= K:
        L = R
        ans |= b
print(ans)

Problem: p03215
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[]
for i in range(n):
    c=0
    for j in a[i:]:
        c+=j
        l.append(c)
t=0
for i in range(40,0,-1):
    s=t+2**i
    c=0
    for j in l:
        if j&s==s:
            c+=1
    else:
        if k<=c:
            t=s
print(t)

Failing test case input:
8 2
1 0 16 2 7 8 6 6

Expected output:
45


Actual output:
44


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[]
for i in range(n):
    c=0
    for j in a[i:]:
        c+=j
        l.append(c)
t=0
for i in range(40,-1,-1):
    s=2**i
    b=[u for u in l if s&u!=0]
    if len(b)>=k:
        l=b
        t+=s
print(t)
Problem: p03215
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(n):
  x=0
  for j in range(i,n):
    x+=a[j]
    b.append(x)
ans=0
l=len(b)
for i in range(40,0,-1):
  x=0
  s=2**i-1
  for j in range(l):
    if b[j]&(ans+s)==ans+s:x+=1
  if x>=k:ans+=s
print(ans)

Failing test case input:
8 8
7 1 11 0 14 5 6 4

Expected output:
32


Actual output:
4


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(n):
  x=0
  for j in range(i,n):
    x+=a[j]
    b.append(x)
ans=0
l=len(b)
for i in range(40,-1,-1):
  x=0
  s=2**i
  for j in range(l):
    if b[j]&(ans+s)==ans+s:x+=1
  if x>=k:ans+=s
print(ans)

Problem: p03215
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(n):
  x=0
  for j in range(i,n):
    x+=a[j]
    b.append(x)
ans=0
l=len(b)
for i in range(40,0,-1):
  x=0
  s=2**i
  for j in range(l):
    if b[j]&(ans+s)==ans+s:x+=1
  if x>=k:ans+=s
print(ans)

Failing test case input:
8 1
8 1 27 1 7 8 10 1

Expected output:
63


Actual output:
62


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[]
for i in range(n):
  x=0
  for j in range(i,n):
    x+=a[j]
    b.append(x)
ans=0
l=len(b)
for i in range(40,-1,-1):
  x=0
  s=2**i
  for j in range(l):
    if b[j]&(ans+s)==ans+s:x+=1
  if x>=k:ans+=s
print(ans)

Problem: p03215
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from bisect import bisect_left as bl
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[]
for i in range(n):
    c=0
    for j in a[i:]:
        c+=j
        l.append(c)
t=0
for i in range(40,0,-1):
    s=t+2**i
    c=0
    for j in l[bl(l,t):]:
        if j&s==s:
            c+=1
    else:
        if k<=c:
            t=s
print(t)

Failing test case input:
8 6
8 1 27 2 7 8 7 6

Expected output:
48


Actual output:
32


Fixed submission (verdict: Accepted):
n,k=map(int,input().split())
a=list(map(int,input().split()))
l=[]
for i in range(n):
    c=0
    for j in a[i:]:
        c+=j
        l.append(c)
t=0
for i in range(40,-1,-1):
    s=2**i
    b=[u for u in l if s&u!=0]
    if len(b)>=k:
        l=b
        t+=s
print(t)
Problem: p03215
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N,K=map(int,input().split())
alist=list(map(int,input().split()))

sum_list=[]
for i in range(N):
  s=0
  for j in range(i,N):
    s+=alist[j]
    sum_list.append(s)
    
sum_list.sort(reverse=True)


answer=sum_list[0]
for i in range(1,K):
  answer&=sum_list[i]
  
print(answer)

Failing test case input:
8 6
8 1 27 2 7 8 6 6

Expected output:
48


Actual output:
0


Fixed submission (verdict: Accepted):
N,K=map(int,input().split())
alist=list(map(int,input().split()))

sum_list=[]
for i in range(N):
  s=0
  for j in range(i,N):
    s+=alist[j]
    sum_list.append(s)
    
sum_list.sort(reverse=True)


answer=0
for i in reversed(range(41)):
  x=2**i
  cnt=0
  for s in sum_list:
    if answer+x>s:
      break
    elif (answer+x)&s==answer+x:
      cnt+=1
      if cnt>=K:
        answer+=x
        break
  
print(answer)

Problem: p03215
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

from pprint import pprint
import itertools

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

rui = [0]
tmp = 0
for a in an:
    rui.append(tmp+a)
    tmp += a

sum_list = [] 

for l in range(1,N+1):
    for r in range(l,N+1):
        tmp = rui[r] - rui[l-1]
        sum_list.append(tmp)

bin_list = [[0 for _ in range(32)] for _ in range(len(sum_list))]


Failing test case input:
8 3
13 1 11 2 14 5 6 4

Expected output:
42


Actual output:

Fixed submission (verdict: Accepted):

from pprint import pprint
import itertools

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

rui = [0]
tmp = 0
for a in an:
    rui.append(tmp+a)
    tmp += a

sum_list = [] 

for l in range(1,N+1):
    for r in range(l,N+1):
        tmp = rui[r] - rui[l-1]
        sum_list.append(tmp)

max_val = max(sum_list)
max_2pow = len(bin(max_val)[2:])
ans = 0

while max_2pow > 0:
    tmp = ans + 2**(max_2pow-1)
    if sum([1 for v in sum_list if v & tmp == tmp]) >= K:
        ans += 2**(max_2pow-1)
    max_2pow -= 1

print(ans)

Problem: p03215
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
from itertools import accumulate, combinations

read = sys.stdin.read

N, K, *a = map(int, read().split())

a = accumulate([0] + a)
seq = []
for i, j in combinations(a, 2):
    seq.append(j - i)

m = (10 ** 9 * 1000).bit_length()
answer = 0
bit = 1 << m
for _ in range(m):
    tmp = bit + answer
    if len([i for i in seq if i & tmp == tmp]) >= K:
        answer = tmp
    bit >>= 1

print(answer)

Failing test case input:
8 1
1 1 8 2 7 8 6 6

Expected output:
39


Actual output:
38


Fixed submission (verdict: Accepted):
import sys
from itertools import accumulate, combinations

read = sys.stdin.read

N, K, *a = map(int, read().split())

a = accumulate([0] + a)
seq = []
for i, j in combinations(a, 2):
    seq.append(j - i)

m = (10 ** 9 * 1000).bit_length()
answer = 0
bit = 1 << (m - 1)
for _ in range(m):
    tmp = bit + answer
    if len([i for i in seq if i & tmp == tmp]) >= K:
        answer = tmp
    bit >>= 1

print(answer)
Problem: p03215
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N, K = map(int, input().split())
A = list(map(int, input().split()))

cumA = [0] * (N + 1)
for i in range(1, N + 1):
    cumA[i] = cumA[i - 1] + A[i - 1]

beauty = []
for left in range(N):
    for right in range(left + 1, N + 1):
        b = cumA[right] - cumA[left]
        beauty.append(b)

beauty.sort(reverse=True)
ans = beauty[0]

for b in beauty[:K]:
    ans &= b

print(ans)

Failing test case input:
8 6
8 1 27 2 7 8 7 6

Expected output:
48


Actual output:
0


Fixed submission (verdict: Accepted):
N, K = map(int, input().split())
A = list(map(int, input().split()))

cumA = [0] * (N + 1)
for i in range(1, N + 1):
    cumA[i] = cumA[i - 1] + A[i - 1]

beauty = []
for left in range(N):
    for right in range(left + 1, N + 1):
        b = cumA[right] - cumA[left]
        beauty.append(b)

ans = 0
M = max(beauty).bit_length()

for digit in range(M)[:: -1]:
    new = ans + (1 << digit)
    cnt = 0
    for b in beauty:
        if b & new == new:
            cnt += 1
    if cnt >= K:
        ans = new

print(ans)

Problem: p03215
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from itertools import accumulate
from functools import reduce

n,k=map(int,input().split())
*ac,=accumulate([0]+list(map(int,input().split())))

l=[]
for i in range(n+1):
  for j in range(i+1,n+1):
    l.append(ac[j]-ac[i])

l.sort(reverse=True)
print(l[k-1])

Failing test case input:
8 7
7 1 11 2 14 5 8 4

Expected output:
32


Actual output:
40


Fixed submission (verdict: Accepted):
from itertools import accumulate as ac

n,k=map(int,input().split())
*a,=ac([0]+list(map(int,input().split())))

l=[a[j]-a[i] for i in range(n+1) for j in range(i+1,n+1)]
f=lambda n:sum(map(lambda x:x&n==n,l))

ans=0
for i in range(41)[::-1]:
    if f(ans|1<<i)>=k:
        ans|=1<<i

print(ans)

Problem: p03215
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from functools import reduce
from itertools import accumulate
N, K = map(int, input().split())
A = list(map(int, input().split()))

A_acc = [0]+list(accumulate(A))
cand = []

for l in range(N):
    for r in range(l+1, N+1):
        cand.append(A_acc[r]-A_acc[l])
cand = sorted(cand)


ans = int(reduce(lambda x, y: x & y, cand[-K:], cand[-1]))
print(ans)


Failing test case input:
8 8
0 1 10 1 2 1 10 1

Expected output:
14


Actual output:
8


Fixed submission (verdict: Accepted):
from itertools import accumulate

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

A_acc = [0]+list(accumulate(A))
cand = []

for l in range(N):
    for r in range(l+1, N+1):
        cand.append(A_acc[r]-A_acc[l])
cand = sorted(cand)
ans = 0
for i in reversed(range(41)):
    k_candidates = []
    for c in cand:
        if c & (1 << i):
            k_candidates.append(c)
    if len(k_candidates) >= K:
        ans += 1 << i
        cand = k_candidates
print(ans)
Problem: p03215
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from itertools import accumulate
from functools import reduce

n,k=map(int,input().split())
*ac,=accumulate([0]+list(map(int,input().split())))

l=[]
for i in range(n+1):
  for j in range(i+1,n+1):
    l.append(ac[j]-ac[i])

l.sort(reverse=True)
print(reduce(lambda x,y:x&y,l[:k]))

Failing test case input:
8 8
13 1 11 2 7 5 6 4

Expected output:
16


Actual output:
0


Fixed submission (verdict: Accepted):
from itertools import accumulate as ac

n,k=map(int,input().split())
*a,=ac([0]+list(map(int,input().split())))

l=[a[j]-a[i] for i in range(n+1) for j in range(i+1,n+1)]
f=lambda n:sum(map(lambda x:x&n==n,l))

ans=0
for i in range(41)[::-1]:
    if f(ans|1<<i)>=k:
        ans|=1<<i

print(ans)
Problem: p02866
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from sys import stdin
import collections
def main():
    n = int(stdin.readline().rstrip())
    D = [int(i) for i in input().split()]
    hash = collections.Counter(D)
    count = hash[0]
    if(count != 0 or count != 1):
        print(0)
        return
    for i in range(1, max(D)+1):
        count *= hash[i-1] ** hash[i]
    print(count%998244353)
    
if __name__ == '__main__':
    main()


Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
0


Fixed submission (verdict: Accepted):
from sys import stdin
import collections
def main():
    n = int(stdin.readline().rstrip())
    D = [int(i) for i in input().split()]
    hash = collections.Counter(D)
    count = hash[0]
    if(count != 1 or D[0] != 0):
        print(0)
        return
    for i in range(1, max(D)+1):
        count *= hash[i-1] ** hash[i]
    print(count%998244353)
    
if __name__ == '__main__':
    main()

Problem: p02866
Buggy submission (Python (3.8.2), verdict: Wrong Answer):








n = int(input())

a = sorted(list(map(int, input().split())))
d = {}
for av in a:
    if av not in d:
        d[av] = 1
    else:
        d[av] += 1

if a[0] != 0 or d[0] != 1 or len(set(d.keys())) != a[-1] + 1:
    print(0)
    exit()
MOD = 998244353
ans = 1
for i in range(1, a[-1]):
    ans *= pow(d[i - 1], d[i], MOD)


print(ans % MOD)

Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
1


Fixed submission (verdict: Accepted):





n = int(input())
a = list(map(int, input().split()))
if a[0] != 0:
    print(0)
    exit()
a = sorted(a)
d = {}
for av in a:
    if av not in d:
        d[av] = 1
    else:
        d[av] += 1

if a[0] != 0 or d[0] != 1 or len(set(d.keys())) != a[-1] + 1:
    print(0)
    exit()
MOD = 998244353
ans = 1
for i in range(2, a[-1] + 1):
    ans *= pow(d[i - 1], d[i], MOD)
print(ans % MOD)

Problem: p02866
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
N = int(input())
D = list(map(int, input().split()))

if D[0] == 0:
    print(0)
else:
    tmp = [0 for _ in range(10 ** 5)]
    for i in range(N):
        tmp[D[i]] += 1

    ans = 1
    flag = False
    for i in range(10 ** 5 - 1):
        if tmp[10 ** 5-i-1] != 0:
            flag = True

        if flag:
            ans *= tmp[10 ** 5 - i - 2] ** tmp[10 ** 5 - i - 1]
            ans = ans % 998244353

    print(ans) 


Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
else:
    tmp = [0 for _ in range(10 ** 5)]
    for i in range(N):
        tmp[D[i]] += 1

    if tmp[0] != 1:
        print(0)
    else:
        ans = 1
        flag = False
        flag2 = False
        for i in range(1, 10 ** 5 - 1):

            if flag2 and tmp[i+1] != 0:
                ans = 0
                break

            if tmp[i+1] == 0:
                flag2 = True

            ans = (ans * (tmp[i] ** tmp[i+1])) % 998244353

        print(ans)
Problem: p02866
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n=int(input())
d=sorted(list(map(int, input().split())))
num=[]

for i in range(max(d)+1):
    count=d.count(i)
    num.append(count)
print(num)
ans=1
if d[0]!=0:
    print(0)
else:
    for i in range(1, max(d)+1):
        ans*=num[i-1]**num[i]
print(ans)


Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
[1, 2, 1]
2


Fixed submission (verdict: Accepted):
import collections
n=int(input())
d=list(map(int, input().split()))
num=collections.Counter(d)


ans=1
for i in range(1, max(d)+1):
    
    
    ans*=num[i-1]**num[i]

if d[0]!=0 or d.count(0)!=1:
    print(0)
else:
    print(ans%998244353)

Problem: p02866
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
n = int(input())
d = list(map(int, input().split()))
m = {}
ans = 1

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

for i in range(n):
    num = d[i]
    if num in m:
        m[num] += 1
    else:
        m[num] = 1

if len(m) < n:
    print(0)
    sys.exit()



maxV = max(m.keys())



for i in range(0, maxV):
    if i not in m or i + 1 not in m:
        print(0)
        sys.exit()
    prevCnt = m[i]
    curCnt = m[i+1]
    
    
    ans *= prevCnt ** curCnt
    

print(ans % 998244353)







Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
0


Fixed submission (verdict: Accepted):
import sys
n = int(input())
d = list(map(int, input().split()))
m = {}
ans = 1

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

if d.count(0) > 1:
    print(0)
    sys.exit()

for i in range(n):
    num = d[i]
    if num in m:
        m[num] += 1
    else:
        m[num] = 1







maxV = max(m.keys())



for i in range(0, maxV):
    if i not in m or i + 1 not in m:
        print(0)
        sys.exit()
    prevCnt = m[i]
    curCnt = m[i+1]
    
    
    ans *= prevCnt ** curCnt
    

print(ans % 998244353)

Problem: p02866
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
ls = list(map(int, input().split(' ')))
n = 100000
ls = [p%4 for p in range(n)]
m = max(set(ls))
d = {}
for l in ls:
    d[l] = d.get(l, 0) + 1
ans = 0 if ls[0] != 0 else 1
for i in range(1, m+1):
    if i not in d:
        ans = 0
    ans = (ans * (d.get(i-1, 0) ** d.get(i, 0)))
print(ans % 998244353)

Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
621284687


Fixed submission (verdict: Accepted):
n = int(input())
ls = list(map(int, input().split(' ')))
m = max(set(ls))
d = {}
for l in ls:
    d[l] = d.get(l, 0) + 1
ans = 0 if (ls[0] != 0 or d.get(0) >= 2) else 1
for i in range(1, m+1):
    if i not in d:
        ans = 0
    ans = (ans * (d.get(i-1, 0) ** d.get(i, 0))) % 998244353 
print(ans)
Problem: p02866
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n,*a=map(int,open(0).read().split())
mod=998244353
d={}
for i in a:
  d[i]=d.get(i,0)+1
b=list(d.items())
b.sort()
ans=1
if a[0]!=0 or len(b)!=b[-1][0]:
    ans=0
for i in range(1,len(b)):
    ans*=b[i-1][1]**b[i][1]
    ans%=mod
print(ans)

Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
0


Fixed submission (verdict: Accepted):
n,*a=map(int,open(0).read().split())
mod=998244353
d={}
for i in a:
  d[i]=d.get(i,0)+1
b=list(d.items())
b.sort()
ans=1
if a[0]!=0 or len(b)!=b[-1][0]+1 or b[0][1]!=1:
    ans=0
for i in range(1,len(b)):
    ans*=b[i-1][1]**b[i][1]
    ans%=mod
print(ans)

Problem: p02866
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
from functools import reduce
n = int(input())
d = (int(s) for s in input().split())
if next(d) != 0:
    print(0)
    quit(0)
c = Counter(d)
if c[0] != 1:
    print(0)
    quit(0)
print(reduce(lambda x, y: x * y, (c[k - 1] ** x if k > 1 else 1 for k, x in c.items()), 1) % 998244353)




Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
0


Fixed submission (verdict: Accepted):
from collections import Counter
from functools import reduce
n = int(input())
d = (int(s) for s in input().split())
if next(d) != 0:
    print(0)
    quit(0)
c = Counter(d)
if c[0] != 0:
    print(0)
    quit(0)
print(reduce(lambda x, y: x * y, (c[k - 1] ** x if k > 1 else 1 for k, x in c.items()), 1) % 998244353)

Problem: p02866
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def find(D):
    if D[0]!=0:
        return 0
    
    count=[0 for _ in range(len(D))]
    MAX=max(D)
    
    ans=1
    for i in range(len(count)):
        if count[i]>0:
            MAX=i
    
    if count[0]!=1:
        return 0
    
    for i in range(1,MAX+1):
        ans=ans*pow(count[i-1],count[i],998244353)
        ans%=998244353
    return ans
N=int(input())
D=list(map(int,input().strip().split()))
print(find(D))

Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
0


Fixed submission (verdict: Accepted):
def find(D):
    if D[0]!=0:
        return 0
    
    count=[0 for _ in range(len(D))]
    MAX=max(D)
    
    ans=1
    for x in D:
        count[x]+=1
    
    if count[0]!=1:
        return 0
    
    for i in range(1,MAX+1):
        ans=ans*pow(count[i-1],count[i],998244353)
        ans%=998244353
    return ans
N=int(input())
D=list(map(int,input().strip().split()))
print(find(D))
Problem: p02866
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from collections import Counter
import math
n = int(input())
d = list(map(int, input().split()))

setD = list(set(d))
setD.sort()
ans = 1
nodeMulti = 1

if d[0] > 0:
        print(0)
        exit()
else:
        c = Counter(d)
        
        
        
        

        for i in range(len(setD)-1):
                print(c[setD[i]] + c[setD[i+1]] - 1)
                ans *= (c[setD[i]] + c[setD[i+1]] - 1)

        print(ans%998244353)

Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
2
2
4


Fixed submission (verdict: Accepted):
from collections import Counter
import math
n = int(input())
d = list(map(int, input().split()))

for i in range(1, n):
        if d[i] == 0:
                print(0)
                exit()

ans = 1
setD = list(set(d))




if d[0] > 0:
        print(0)
else:
        c = Counter(d)
        
        
        
        
        
        
        

        for _d in setD:
                if _d != 0:
                        ans *= c[_d - 1] ** c[_d]

        print(ans%998244353)

Problem: p02866
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
import collections


d = list(map(int,input().split()))
n = len(d)
MOD = 998244353
  

cnt = dict(collections.Counter(d))

try:
  if cnt[0]==1:
    ans = 1
    for i in range(len(dict(cnt))-1):
      val_1 = cnt[i]
      val_2 = cnt[i+1]
      print(val_1,val_2)
      ans *= (val_1**val_2)
    print(ans%MOD)
  else:
    print(0)
except KeyError:
  print(0)

Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
0


Fixed submission (verdict: Accepted):
import collections
 
n = int(input())
d = list(map(int,input().split()))
MOD = 998244353

if d[0]!=0:
  print(0)
  exit()
  

cnt = dict(collections.Counter(d))

if cnt[0]==1:
  m = max(cnt)
  
  for i in range(m):
    if i not in cnt:
      print(0)
      exit()
  ans = 1
  for i in range(m):
    val_1 = cnt[i]
    val_2 = cnt[i+1]
    ans *= (val_1**val_2)%MOD
 
  print(ans%MOD)
else:
  print(0)

Problem: p02866
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import sys
import collections
sys.setrecursionlimit(10**9)
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    D=list(map(int,input().split()))
    c=collections.Counter(D)
    k=list(c.keys())
    v=list(c.values())
    ans=len(k)
    for i in range(len(k)-1):
        ans=ans*(c[i]**c[i+1])%998244353
    print(ans)

if __name__ == '__main__':
    main()


Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
6


Fixed submission (verdict: Accepted):
import sys
import collections
sys.setrecursionlimit(10**9)
def input():
    return sys.stdin.readline().rstrip()

def main():
    N=int(input())
    D=list(map(int,input().split()))
    c=collections.Counter(D)
    k=list(c.keys())
    v=list(c.values())
    ans=1 if c[0] == 1 and D[0] == 0 else 0
    for i in range(max(k)):
        ans*=c[i]**c[i+1]
        ans%=998244353
        if ans == 0:
            break
    print(ans)

if __name__ == '__main__':
    main()
Problem: p02866
Buggy submission (Python (3.4.3), verdict: Wrong Answer):



from collections import Counter,deque


from sys import stdin,setrecursionlimit







setrecursionlimit(10**6)
input=stdin.readline

n=int(input())
d=[int(i) for i in input().split()]
m=max(d)
if d[0]!=0:
    print(0)
    exit()
dst=[0]*(m+1)
ans=1
for i in d: dst[i]+=1
print(*dst)
if dst[0]>1:
    print(0)
    exit()
for i in range(2,m+1):
    if dst[i]==0:
        print(0)
        exit()
    ans*=dst[i-1]**dst[i]
print(ans%998244353)

Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
1 2 1
2


Fixed submission (verdict: Accepted):



from collections import Counter,deque


from sys import stdin,setrecursionlimit







setrecursionlimit(10**6)
input=stdin.readline

n=int(input())
d=[int(i) for i in input().split()]
m=max(d)
if d[0]!=0:
    print(0)
    exit()
dst=[0]*(m+1)
ans=1
for i in d: dst[i]+=1

if dst[0]>1:
    print(0)
    exit()
for i in range(2,m+1):
    if dst[i]==0:
        print(0)
        exit()
    ans*=dst[i-1]**dst[i]
print(ans%998244353)

Problem: p02866
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
d=list(map(int,input().split()))
if d[0]!=0:
    print(0)
    exit()
del d[0]
for i in range(n-1):
    if d[i]==0:
        print(0)
        exit()
dcnt=[0]*(n)
for i in range(n-1):
    dcnt[d[i]]+=1
for j in range(n-1,-1,-1):
    if dcnt[j]==0:
        del dcnt[j]
    else:
        break
if len(dcnt)==0:
    print(0)
    exit()
sum=1
for i in range(1,len(dcnt)):
    sum*=pow(dcnt[i-1],dcnt[i])
print(sum)


Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
0


Fixed submission (verdict: Accepted):
n=int(input())
d=list(map(int,input().split()))
if d[0]!=0:
    print(0)
    exit()
del d[0]
for i in range(n-1):
    if d[i]==0:
        print(0)
        exit()
dcnt=[0]*(n)
for i in range(n-1):
    dcnt[d[i]]+=1
for j in range(n-1,-1,-1):
    if dcnt[j]==0:
        del dcnt[j]
    else:
        break
if len(dcnt)==0:
    print(0)
    exit()
dcnt[0]=1
sum=1
for i in range(1,len(dcnt)):
    sum*=pow(dcnt[i-1],dcnt[i])
    sum%=998244353
print(sum)

Problem: p02866
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections
N = int(input())

D = [int(a) for a in input().split() ]

counted = collections.Counter(D)

if D[0] != 0 or counted[0] !=1:
    print("0")
    exit()


result = 1
x = counted[1]
for i in range(2,N+1):
    y = counted[i]
    if y!= 0:
        result = result * pow(x,y) %998244353
        x = y
    else:
        print("0")
        exit()
print(result)


Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
0


Fixed submission (verdict: Accepted):
import collections
N = int(input())

D = [int(a) for a in input().split() ]

counted = collections.Counter(D)

if D[0] != 0 or counted[0] !=1:
    print("0")
    exit()


result = 1
x = counted[1]
for i in range(2,N+1):
    y = counted[i]
    result = result * pow(x,y) %998244353
    x = y
print(result)
Problem: p02866
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
D = list(map(int, input().split()))
mod = 998244353
if D[0] != 0:
  print(0)
  exit()
ans = 1
A = [0]*(max(D)+1)



for i in range(N):
  A.append(D.count(i))

for i in range(max(D)+1):
  if A[i] == 0:
    print(0)
    exit()
  if i > 0:
    ans *= pow(A[i-1], A[i], mod) % mod
print(ans % mod)

Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
D = list(map(int, input().split()))
mod = 998244353
ans = 1
A = [0]*(max(D)+1)
for i in range(N):
  A[D[i]] += 1
if D[0] != 0 or not all(D[1:]) or not all(A):
  print(0)
  exit()
if D[0] != 0:
  print(0)
  exit()
for i in range(1, max(D)+1):



  ans = ans * pow(A[i-1], A[i], mod) % mod
print(ans % mod)

Problem: p02866
Buggy submission (Python (3.4.3), verdict: Wrong Answer):





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

cnt = [0 for i in range(N)]

flg = 1
if D[0]!=0:
    flg = 0
for i in range(N):
    if D[i]==0 and i!=0:
        flg = 0
    else:
        cnt[D[i]] += 1
print(cnt)
ans = 1
mod = 998244353
flg2 = 1
for i in range(1,N):
    if cnt[i]>0 and flg2:
        ans *= cnt[i-1]**cnt[i]
        ans %= mod
    elif cnt[i]>0 and (not(flg2)):
        flg = 0
    else:
        flg2 = 0
print(ans*flg)
    
    


Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
[1, 2, 1, 0]
2


Fixed submission (verdict: Accepted):





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

cnt = [0 for i in range(N)]

flg = 1
if D[0]!=0:
    flg = 0
for i in range(N):
    if D[i]==0 and i!=0:
        flg = 0
    else:
        cnt[D[i]] += 1

ans = 1
mod = 998244353
flg2 = 1
for i in range(1,N):
    if cnt[i]>0 and flg2:
        ans *= cnt[i-1]**cnt[i]
        ans %= mod
    elif cnt[i]>0 and (not(flg2)):
        flg = 0
    else:
        flg2 = 0
print(ans*flg)

Problem: p02866
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N = int(input())
d_list = list(map(int,input().split()))

dist = [0] * 10**5
max_d = 0
for d in d_list:
    dist[d-1] += 1
    max_d = max(max_d, d)

MOD = 998244353
if d_list[0] != 1:
    print(0)
    exit()

ans = 1
for i in range(max_d-1):
    if dist[i]==0 or dist[i+1]==0:
        print(0)
        exit()
    ans = (ans*(dist[i]**dist[i+1]))%MOD
print(ans)

Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
d_list = list(map(int,input().split()))

dist = [0] * 10**5
max_d = 0
for d in d_list:
    dist[d] += 1
    max_d = max(max_d, d)

MOD = 998244353
if d_list[0] != 0:
    print(0)
    exit()
elif dist[0]>1:
    print(0)
    exit()

ans = 1
for i in range(max_d):
    if dist[i] == 0 or dist[i+1] ==0:
        print(0)
        exit()
    ans *= (dist[i]**dist[i+1])
    ans %= MOD

print(ans)
Problem: p02866
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
mod = 998244353
ans = 1

n = int(readline())
d = list(map(int, readline().split()))

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

import collections
d_count = collections.Counter(d)

for i in range(n):
     ans = ans * (d_count[i] ** d_count[i+1]) % mod
     
     if i > 0 and d_count[i] == 0 :
         print(0)
         sys.exit()
print(ans)

Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
0


Fixed submission (verdict: Accepted):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)
mod = 998244353
ans = 1



n = int(readline())
d = list(map(int, readline().split()))

import collections
d_count = collections.Counter(d)

if d[0] != 0:
    print(0)
    sys.exit()
if d_count[0] != 1:
    print(0)
    sys.exit()
    

for i in range(n):
     ans = ans * (d_count[i] ** d_count[i+1]) % mod
     
     if d_count[i] == 0 and d_count[i+1] != 0:
         print(0)
         sys.exit()
print(ans)

Problem: p02866
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
D = [int(i) for i in input().split()]

key = max(D) + 1
count_list = [0] * key

for i in range(N):
    count_list[D[i]] += 1

counter = 1
if 0 in count_list:
    counter = 0

if D[0] != 1:
    counter = 0

for i in range(1, key - 1):
    counter *= count_list[i]**count_list[i + 1]

print(counter%998244353)

Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
0


Fixed submission (verdict: Accepted):
N = int(input())
D = [int(i) for i in input().split()]

key = max(D) + 1
count_list = [0] * key

for i in range(N):
    count_list[D[i]] += 1

counter = 1
if 0 in count_list:
    counter = 0

if count_list[0] != 1:
    counter = 0

if D[0] != 0:
    counter = 0 

for i in range(1, key - 1):
    counter *= count_list[i]**count_list[i + 1]

print(counter%998244353)
Problem: p02866
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import sys
import collections


def solve():
    MOD = 998244353
    N, *d_l = map(int, open(0).read().split())
    ans = 1
    
    if d_l[0] != 0:
        print(0)
        sys.exit()
    
    d_max = max(d_l)
    count_dic = collections.Counter(d_l)
    if count_dic[0] != 0:
        print(0)
        sys.exit()
    
    for i in range(2, d_max+1):
        ans *= count_dic[i-1] ** count_dic[i]
    
    print(ans%MOD)


if __name__ == '__main__':
    solve()

Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
0


Fixed submission (verdict: Accepted):
import sys
import collections


def solve():
    MOD = 998244353
    N, *d_l = map(int, open(0).read().split())
    ans = 1
    
    if d_l[0] != 0:
        print(0)
        sys.exit()
    
    d_max = max(d_l)
    count_dic = collections.Counter(d_l)
    if count_dic[0] != 1:
        print(0)
        sys.exit()
    
    for i in range(2, d_max+1):
        ans *= count_dic[i-1] ** count_dic[i]
    
    print(ans%MOD)


if __name__ == '__main__':
    solve()

Problem: p02866
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
d_list = list(map(int, input().split()))
divider = 998244353

if d_list[0] != 0:
  print(0)
else:
  d_sort = sorted(d_list)
  d = 1
  pre_c = 1
  cur_c = 0
  count = 1
  for i in range(1, n):
    if d_sort[i] == d:
      cur_c += 1
    elif d_sort[i] == d + 1:
      count *= pre_c ** cur_c
      count %= divider
      d += 1
      pre_c = cur_c
      cur_c = 0
    else:
      count = 0
      cur_c = 0
      break
  count *= pre_c ** cur_c
  count %= divider
  print(count)

Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
d_list = list(map(int, input().split()))
divider = 998244353

if d_list[0] != 0:
  print(0)
else:
  d_sort = sorted(d_list)
  d = 1
  pre_c = 1
  cur_c = 0
  count = 1
  for i in range(1, n):
    if d_sort[i] == d:
      cur_c += 1
    elif d_sort[i] == d + 1:
      count *= pre_c ** cur_c
      count %= divider
      d += 1
      pre_c = cur_c
      cur_c = 1
    else:
      count = 0
      cur_c = 0
      break
  count *= pre_c ** cur_c
  count %= divider
  print(count)
Problem: p02866
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
import collections

n = int(input())
d = list(map(int, input().split()))
for i in range(len(d)):
    if i == 0 and d[i] != 0:
        print(0)
        exit()
    if i != 0 and d[i] == 0:
        print(0)
        exit()

e = collections.Counter(d)

e2 = dict(sorted(e.items()))
e3 = list(e2.values())
e4 = list(e2.keys())
print(e2)
print(e3)
print(e4)

tmp = 0
for i in e4:
    if i - tmp >= 2:
        print(0)
        exit()
    tmp = i

cntsum = 1
for i in range(1, len(e3)):
    cntsum *= e3[i - 1] ** e3[i]
print(cntsum%998244353)


Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
{0: 1, 1: 2, 2: 1}
[1, 2, 1]
[0, 1, 2]
2


Fixed submission (verdict: Accepted):
import collections
 
n = int(input())
d = list(map(int, input().split()))
for i in range(len(d)):
    if i == 0 and d[i] != 0:
        print(0)
        exit()
    if i != 0 and d[i] == 0:
        print(0)
        exit()
 
e = collections.Counter(d)
 
e2 = dict(sorted(e.items()))
e3 = list(e2.values())
e4 = list(e2.keys())



 
tmp = 0
for i in e4:
    if i - tmp >= 2:
        print(0)
        exit()
    tmp = i
cntsum = 1
for i in range(1, len(e3)):
    cntsum *= e3[i - 1] ** e3[i]
print(cntsum%998244353)

Problem: p02866
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import collections

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

ans = 1
m = max(D)
c = collections.Counter(D)

if 0 not in c.keys() or c[0] != 0:
    print(0)
    exit()

temp = 1
for i in range(1, m+1):
    if i not in c.keys():
        print(0)
        exit()
    ans *= temp**c[i]
    temp = c[i]

print(ans % 998244353)

Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
0


Fixed submission (verdict: Accepted):
import collections

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

ans = 1
m = max(D)
c = collections.Counter(D)

if 0 not in c.keys() or (c[0] != 1 or D[0] != 0):
    print(0)
    exit()

temp = 1
for i in range(1, m+1):
    if i not in c.keys():
        print(0)
        exit()
    ans *= temp**c[i]
    temp = c[i]
    if ans > 998244353:
        ans %= 998244353  

print(ans % 998244353)

Problem: p02866
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())
d=list(map(int,input().split()))
x=max(d)
li=[0]*(x+1)
for i in range(n):
    li[d[i]]+=1
if d[0]!=0 or li[0]!=1:
    print(0) 
else:
    ans=li[1]
    for i in range(2,len(li)):
        ans*=pow(li[i-1],li[i],998244353)   
    print(ans%998244353)      

Failing test case input:
4
0 1 1 2

Expected output:
2

Actual output:
4


Fixed submission (verdict: Accepted):
n=int(input())
d=list(map(int,input().split()))
x=max(d)
li=[0]*(x+1)
for i in range(n):
    li[d[i]]+=1
if d[0]!=0 or li[0]!=1:
    print(0) 
else:
    ans=1
    for i in range(2,len(li)):
        ans*=pow(li[i-1],li[i],998244353)   
    print(ans%998244353)