ZhenlongDai/ACPR huggingface dataset:
Problem: p03069
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()

def inverse(num, index, first):
    offset = 0
    if first == '*':
        offset = 1
    count = 0
    for n, i in enumerate(num):
        if n <= index and n % 2 == offset:
            count += i
        elif n > index and n % 2 != offset:
            count += i
    return count

num = []
first = s[0]
end = s[-1]
pre = first
count = 0
for c in s:
    if c == pre:
        count += 1
    else:
        num.append(count)
        count = 1
        pre = c
num.append(count)

if len(num) == 1:
    print(0)
else:
    minlist = []
    for i in range(len(num)):
        minlist.append(inverse(num, i, first))
    print(min(minlist))



Failing test case input:
5
.##.

Expected output:
2

Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
s = input()

num = []
first = s[0]
end = s[-1]
pre = first
count = 0
for c in s:
    if c == pre:
        count += 1
    else:
        num.append(count)
        count = 1
        pre = c
num.append(count)

if len(num) == 1:
    print(0)
else:
    b = 0
    w = n
    offset = 0
    if first == '
        offset = 1
    w = sum(num[offset::2])
    minlist = [b + w]
    for i in range(len(num)):
        if i % 2 == offset:
            w -= num[i]
        else:
            b += num[i]
        minlist.append(b + w)
    print(min(minlist))

Problem: p03069
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
N = int(input())
S = input()
list_S = list(S)
N1 = 0
X = list_S.count('.')

if N == X:
    print('0')
else:
    for N in list_S:
        if list_S[N1] == '.':
            N1 += 1
        else:
            list_SS = list_S[N1:]
            X1 = list_SS.count('.')
            print(X1)
            break

Failing test case input:
5
.##.

Expected output:
2

Actual output:
1


Fixed submission (verdict: Accepted):
N = int(input())
S = input()                                                      
list_S = list(S)
N1 = 0
list_X =[]
X = list_S.count('.')
list_X.append(X)
    
for color in list_S:
    if list_S[N1] == '.':
        X -= 1
        list_X.append(X)
        N1 +=1
    else:
        X += 1
        list_X.append(X)
        N1 +=1

X = list_S.count('
list_X.append(X)

X_MIN = min(list_X)
print(X_MIN)

Problem: p03069
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
ans = 0
cnt = 0
res = 0
for i in s:
    if i==".":
        ans += 1
    else:
        res += 1
for i in s:
    if i==".":
        cnt += 1
    else:
        break

print(min(ans-cnt,res))

Failing test case input:
5
.##.

Expected output:
2

Actual output:
1


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
cnt = 0
cnt2 = 0
tmp = 0
tmp2 = 0
ans = 10**9
for i in s:
    if i=="
        cnt += 1
    else:
        cnt2 += 1
for i in s:
    if i=="
        tmp += 1
    else:
        tmp2 += 1
    ans = min(ans,tmp+cnt2-tmp2)
print(min(ans,cnt,cnt2))
Problem: p03069
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n = int(input())
s = input()
r = s.count(".")
l = 0

ans = 10**9
for i in s:
    if i == ".":
        r -= 1
    else:
        l += 1
    ans = min(ans,l+r)
print(ans)

Failing test case input:
3
.#

Expected output:
1

Actual output:
0


Fixed submission (verdict: Accepted):
n = int(input())
s = input()
r = s.count(".")
l = 0

ans = l+r
for i in s:
    if i == "
        l += 1
    else:
        r -= 1
    ans = min(ans,l+r)
print(ans)

Problem: p03069
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
n = int(input())
s = input()
from collections import Counter

a = 0
for i in range(n):
    if s[i] == ".":
        a += 1
    else:
        break
        
b = s[a:n]
c = Counter(b)

print(c["."])

Failing test case input:
3
.#

Expected output:
1

Actual output:
0


Fixed submission (verdict: Accepted):
from collections import Counter
INF = 114514191981036436433-4
n = int(input())
s = input()

b = Counter(s)
ans = b["."]

cur = b["."]

for i in range(n):
    if s[i] == "
        cur += 1
    else:
        cur -= 1
        
    ans = min(ans,cur)
    
print(ans)
Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h = int(input())

import math

if h == 1:
    print(1)

else:
    n_attacks = 0
    while h / 2 >= 1:
        n_attacks += 1
        h = math.floor(h/2)

    gsum = 1

    for x in range(n_attacks + 1):
        gsum += 2 ** (x + 1)
        
    print(gsum)

Failing test case input:
1011000011110

Expected output:
1099511627775


Actual output:
2199023255551


Fixed submission (verdict: Accepted):
h = int(input())

import math

if h == 1:
    print(1)

else:
    n_attacks = 0
    while h / 2 >= 1:
        n_attacks += 1
        h = math.floor(h/2)

    gsum = 1

    for x in range(n_attacks):
        gsum += 2 ** (x + 1)
        
    print(gsum)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
H = map(int,input().split())

ans=sum([2**int(1+math.ceil(math.log2(s)))-1 for s in H])

print(ans)

Failing test case input:
1010100001000

Expected output:
1099511627775


Actual output:
2199023255551


Fixed submission (verdict: Accepted):
import math
H = map(int,input().split())

ans=sum([2**int(1+math.floor(math.log2(s)))-1 for s in H])

print(ans)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
H = int(input())
cnt = 0
if H >= 2:
  while H >= 2:
    H = int(H/2)
    cnt += 1
  a = 2 ** cnt
  ans = sum([2**i for i in range(0, cnt, 1)]) + cnt
  print(ans)
            
        
else:
        print(H)
  

Failing test case input:
1010000001000

Expected output:
1099511627775


Actual output:
549755813926


Fixed submission (verdict: Accepted):
H = int(input())
cnt = 0
if H >= 2:
  while H >= 2:
    H = int(H/2)
    cnt += 1
  ans = sum([2**i for i in range(0, cnt+1, 1)])
  print(ans)

else:
  print(H)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
H = int(input())
i = 1
while H > 1:
    i = i + 1
    H = math.floor(H / 2)
print(i ** 2 - i + 1)

Failing test case input:
1111010001010

Expected output:
2199023255551


Actual output:
1641


Fixed submission (verdict: Accepted):
import math
H = int(input())
i = 1
if H == 1:
    print(1)
else:
    while H > 1:
        i = i + 1
        H = math.floor(H / 2)
    print(2 ** i - 1)

Problem: p02786
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
h=int(input())
n=len(list(bin(h)))-1
print(2**n-1)

Failing test case input:
1011000011101

Expected output:
1099511627775


Actual output:
2199023255551


Fixed submission (verdict: Accepted):
h=int(input())
n=len(list(bin(h)))-2
print(2**n-1)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def f(h):
    return 0 if h==0 else 1 + 2*f(int(h/2))

h = int(input())
f(h)


Failing test case input:
1010100001000

Expected output:
1099511627775


Actual output:

Fixed submission (verdict: Accepted):
def f(h):
    return 0 if h==0 else 1 + 2*f(int(h/2))

h = int(input())
print(f(h))
Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
H=int(input())
sum([2**x for x in range(math.floor(math.log2(H))+1)])

Failing test case input:
1010000000000

Expected output:
1099511627775


Actual output:

Fixed submission (verdict: Accepted):
import math
H=int(input())
print(sum([2**x for x in range(math.floor(math.log2(H))+1)]))

Problem: p02786
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
h = int(input())
ans = 0
i = 0
while True:
  if(2**i>=h):
    break
  i+=1
if(i == 0):
  print(1)
else:
  print(2**(i+1)-1)


Failing test case input:
1111000010110

Expected output:
2199023255551


Actual output:
4398046511103


Fixed submission (verdict: Accepted):
h = int(input())
ans = 0
i = 0
while True:
  if(2**i>=h):
    break
  i+=1
if(i == 0):
  print(1)
elif(2**i==h):
  print(2**(i+1)-1)
else:
  print(2**i-1)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h = int(input())
tem = 1
while h/2 > 1:
    tem+=1
    h = h/2
result = 1
print("tem"+str(tem))
for i in range(1,tem+1):
    result += 2**i
print(result)

Failing test case input:
1111000000010

Expected output:
2199023255551


Actual output:
tem41
4398046511103


Fixed submission (verdict: Accepted):
h = int(input())
tem = 1
while h/2 > 1:
    tem+=1
    h = h/2
result = 1
if h==2:
    for i in range(1,tem+1):
        result += 2**i
else:
    for i in range(1,tem):
        result += 2**i
print(result)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
H = int(input())
print(H)
def ref(H,d):
  d = d+1
  if 1 < H:
  	H, d = ref(H/2,d*2)
  return H, d

_, d = ref(H,0)

print(d)

Failing test case input:
1010000001001

Expected output:
1099511627775


Actual output:
1010000001001
2199023255551


Fixed submission (verdict: Accepted):
H = int(input())

def ref(H,d):
  d = d+1
  if 1 < H:
  	H, d = ref(H
  return H, d

_, d = ref(H,0)

print(d)

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

h = int(input())

def sum(list,k):
    s = 0
    for i in range(len(list)-k):
        s = s+ list[i]
    return s



x = math.ceil(math.log2(h*1.0))





print(2**(x+1) - 1)






Failing test case input:
1111100011110

Expected output:
2199023255551


Actual output:
4398046511103


Fixed submission (verdict: Accepted):
import math

h = int(input())

def sum(list,k):
    s = 0
    for i in range(len(list)-k):
        s = s+ list[i]
    return s

x = math.ceil(math.log2((h+1)*1.0))


print(2**x - 1)
Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):






__author_ = 'Maruta Yuzuha'
__version_ = '1.0.0'
__date__ = '2019/12/25'

import math
def main():
    
    s = int(input())
    a = 0  
    b = 0  
    while s > 0:
        s = float(s / 2)
        print(s)
        a += pow(2, b)
        b += 1
        if s < 1:
            break
    print(a)
    return 0

if __name__ == '__main__':
    
    

    
    
    import doctest
    doctest.testmod()

    
    import sys
    sys.exit(main())

Failing test case input:
1010001001000

Expected output:
1099511627775


Actual output:
505000500500.0
252500250250.0
126250125125.0
63125062562.5
31562531281.25
15781265640.625
7890632820.3125
3945316410.15625
1972658205.078125
986329102.5390625
493164551.26953125
246582275.63476562
123291137.81738281
61645568.908691406
30822784.454345703
15411392.227172852
7705696.113586426
3852848.056793213
1926424.0283966064
963212.0141983032
481606.0070991516
240803.0035495758
120401.5017747879
60200.75088739395
30100.375443696976
15050.187721848488
7525.093860924244
3762.546930462122
1881.273465231061
940.6367326155305
470.31836630776525
235.15918315388262
117.57959157694131
58.789795788470656
29.394897894235328
14.697448947117664
7.348724473558832
3.674362236779416
1.837181118389708
0.918590559194854
1099511627775


Fixed submission (verdict: Accepted):






__author_ = 'Maruta Yuzuha'
__version_ = '1.0.0'
__date__ = '2019/12/25'

import math
def main():
    
    s = int(input())
    a = 0  
    b = 0  
    while s > 0:
        s = float(s / 2)
        a += pow(2, b)
        b += 1
        if s < 1:
            break
    print(a)
    return 0

if __name__ == '__main__':
    
    

    
    
    import doctest
    doctest.testmod()

    
    import sys
    sys.exit(main())

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

def main():
    import math

    H = int(input())
    if H == 1:
        print(1)
    else:
        count = int(math.log(H, 2))
        ans = 0
        for i in range(count+1):
            ans += 2 ** (i)
            print(ans)

if __name__ == "__main__":
    main()

Failing test case input:
1011000111110

Expected output:
1099511627775


Actual output:
1
3
7
15
31
63
127
255
511
1023
2047
4095
8191
16383
32767
65535
131071
262143
524287
1048575
2097151
4194303
8388607
16777215
33554431
67108863
134217727
268435455
536870911
1073741823
2147483647
4294967295
8589934591
17179869183
34359738367
68719476735
137438953471
274877906943
549755813887
1099511627775


Fixed submission (verdict: Accepted):

def main():
    import math

    H = int(input())
    if H == 1:
        print(1)
    else:
        count = int(math.log(H, 2))
        ans = 0
        for i in range(count+1):
            ans += 2 ** (i)
        print(ans)

if __name__ == "__main__":
    main()
Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h = int(input())
c = 0
while h >= 2:
  h /= 2
  c += 1
count = 1
for i in range(1,c+1):
  count = count + 2*i
print(count)

Failing test case input:
1010101000010

Expected output:
1099511627775


Actual output:
1561


Fixed submission (verdict: Accepted):
h = int(input())
c = 0
while h >= 2:
  h /= 2
  c += 1
count = 1
for i in range(1,c+1):
  count = count + 2**i
print(count)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
H=int(input())
A=1
if H==1:
    print(1)
else:
    while H>=A:
        A*=2

Failing test case input:
1011000000111

Expected output:
1099511627775


Actual output:

Fixed submission (verdict: Accepted):
H=int(input())
A=1
if H==1:
    print(1)
else:
    while H>=A:
        A*=2
    print(A-1)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
H = int(input())
k = math.log(H,2)
print(int((2**(k+1)-1)))
    

Failing test case input:
1010001000011

Expected output:
1099511627775


Actual output:
2020002000020


Fixed submission (verdict: Accepted):
import math
H = int(input())
k = int(math.log2(H))
print((2**(k+1)-1))

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
H = int(input())

cnt = 0
ans = 0

if H % 4 == 0:
    print((H - 1) * 2 + 1)
    exit()

while H > 1:
    H = H / 2
    if cnt == 0:
        cnt += 1
        ans += 1
    else:
        ans += cnt * 2
        cnt = cnt * 2

print(ans)


Failing test case input:
1010000010000

Expected output:
1099511627775


Actual output:
2020000019999


Fixed submission (verdict: Accepted):
H = int(input())

cnt = 0
ans = 0

while H >= 1:
    H = H / 2
    if cnt == 0:
        cnt += 1
        ans += 1
    else:
        ans += cnt * 2
        cnt = cnt * 2

print(ans)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
H = int(input())
count = int((1-2**(math.log2(H)+1)) * -1)
print(count)

Failing test case input:
1011000000111

Expected output:
1099511627775


Actual output:
2022000000221


Fixed submission (verdict: Accepted):
import math
H = int(input())
count = int((1-2**(math.floor(math.log2(H))+1)) * -1)
print(count)

Problem: p02786
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
h = int(input())
num = 1
cnt = 0
while True:
    cnt += num
    h >>= 1
    num *= 2
    if h:
        continue
    print(num)
    break

Failing test case input:
1010100001000

Expected output:
1099511627775


Actual output:
1099511627776


Fixed submission (verdict: Accepted):
h = int(input())
num = 1
cnt = 0
while True:
    cnt += num
    h >>= 1
    num *= 2
    if h:
        continue
    print(cnt)
    break

Problem: p02786
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
N = int(input())

for i in range(100000):
    if 2**i <= N and N<2**(i+1):
        print(2**(i+1))
        break


Failing test case input:
1111000101110

Expected output:
2199023255551


Actual output:
2199023255552


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

for i in range(100000):
    if 2**i <= N and N<2**(i+1):
        print((2**(i+1))-1)
        break
Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):

import math
h = int(input())
i = 0
c = 0
while h != 0:
    c += 2**i
    if h > 1:
        h = math.ceil(h/2)
    else:
        h = 0
    i += 1
print(c)

Failing test case input:
1010000000010

Expected output:
1099511627775


Actual output:
2199023255551


Fixed submission (verdict: Accepted):
import math
h = int(input())
i = 0
c = 0
while h != 0:
    c += 2**i
    if h > 1:
        h = math.floor(h/2)
    else:
        h = 0
    i += 1
print(c)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
H = int(input())
x = math.log2(H)
print(2 ** (x+1) - 1)

Failing test case input:
1111000000011

Expected output:
2199023255551


Actual output:
2222000000020.999


Fixed submission (verdict: Accepted):
import math
H = int(input())
x = math.log2(H)
print(2 ** int(x+1) - 1)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from math import ceil

h = int(input())

ans = 1
i = 0
while h > 1:
    i += 1
    h = ceil(h/2)
for k in range(1, i+1):
    ans += 2**k

print(ans)


Failing test case input:
1011000010111

Expected output:
1099511627775


Actual output:
2199023255551


Fixed submission (verdict: Accepted):
from math import floor

h = int(input())

ans = 1
i = 0
while h != 1:
    i += 1
    h = floor(h/2)
    ans += 2**i

print(ans)

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

integrationEnemy = int(input())
sqrtCount = 0
harf = 10

while True:
    if harf == 1:
        sqrtCount += 1
        break
    elif harf == 0:
        break
    else:
        sqrtCount += 1

    if sqrtCount == 1:
        harf = math.floor(integrationEnemy / 2)
        print(sqrtCount , harf)
    else:
        harf = math.floor(harf / 2)
        print(sqrtCount , harf)

print(sqrtCount)
print(2**(sqrtCount)- 1)

Failing test case input:
1010101000010

Expected output:
1099511627775


Actual output:
1 505050500005
2 252525250002
3 126262625001
4 63131312500
5 31565656250
6 15782828125
7 7891414062
8 3945707031
9 1972853515
10 986426757
11 493213378
12 246606689
13 123303344
14 61651672
15 30825836
16 15412918
17 7706459
18 3853229
19 1926614
20 963307
21 481653
22 240826
23 120413
24 60206
25 30103
26 15051
27 7525
28 3762
29 1881
30 940
31 470
32 235
33 117
34 58
35 29
36 14
37 7
38 3
39 1
40
1099511627775


Fixed submission (verdict: Accepted):
import math

integrationEnemy = int(input())
sqrtCount = 0
harf = 10

while True:
    if harf == 1:
        sqrtCount += 1
        break
    elif harf == 0:
        break
    else:
        sqrtCount += 1

    if sqrtCount == 1:
        harf = math.floor(integrationEnemy / 2)
    else:
        harf = math.floor(harf / 2)

print(2**(sqrtCount)- 1)
Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math

h = int(input())

def f(hp):
    if(hp == 1):
        return 1
    else:
        return (2 * f(math.ceil(hp / 2)) + 1)

print(f(h))

Failing test case input:
1010000011100

Expected output:
1099511627775


Actual output:
2199023255551


Fixed submission (verdict: Accepted):
import math

h = int(input())

def f(hp):
    if(hp == 1):
        return 1
    else:
        return (2 * f(math.floor(hp / 2)) + 1)

print(f(h))

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
 
n = int(input())
kaisu = math.log2(n)
ans = 0
 
for i in range(int(kaisu)):
  ans += 2 ** i
 
print(ans)


Failing test case input:
1111000000010

Expected output:
2199023255551


Actual output:
1099511627775


Fixed submission (verdict: Accepted):
import math
 
n = int(input())
kaisu = math.log2(n) + 1
ans = 0
 
for i in range(int(kaisu)):
  ans += 2 ** i
 
print(ans)

Problem: p02786
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def myfunc(N):
	if(N  <= 1):
		return 1
	return 2 * myfunc(N/2) + 1

if __name__ == "__main__":
	N = int(input())
	print(myfunc(N))


Failing test case input:
1011000011100

Expected output:
1099511627775


Actual output:
2199023255551


Fixed submission (verdict: Accepted):
def myfunc(N):
	if(N  <= 1):
		return 1
	return 2 * myfunc(int(N/2)) + 1

if __name__ == "__main__":
	N = int(input())
	print(myfunc(N))

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h = int(input())
res = 0
while True:
    h = int(h/2)
    res += 1
    if h == 1:
        break
    else:
        pass
print(res+1)

Failing test case input:
1011001011111

Expected output:
1099511627775


Actual output:
40


Fixed submission (verdict: Accepted):
h = int(input())
n = 0
while True:
    if h == 1:
        break
    else:
        h = int(h/2)
        n += 1
res = 2**(n+1) - 1
print(res)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
LogT={1:1}
def  div2(X):
    if X in LogT:
        return LogT[X]
    else:
        v = 1+div2(math.floor(X/2))*2
        LogT[X]=v
        return v

if __name__=='__main__':
    H=int(input())

Failing test case input:
1011000000000

Expected output:
1099511627775


Actual output:

Fixed submission (verdict: Accepted):
import math
LogT={1:1}
def  div2(X):
    if X in LogT:
        return LogT[X]
    else:
        v = 1+div2(math.floor(X/2))*2
        LogT[X]=v
        return v

if __name__=='__main__':
    H=int(input())
    print (div2(H))

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
HP = int(input())
if HP == 1:
  print("1")

else:
  
  print(pow(2,len(bin(HP))-3))

Failing test case input:
1110000011110

Expected output:
2199023255551


Actual output:
1099511627776


Fixed submission (verdict: Accepted):
HP = int(input())
if HP == 1:
  print("1")

else:
  
  print(pow(2,len(bin(HP))-2)-1)
Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h = int(input())

count = 0
n = 1
while (h > 1):
   h = int(h / 2)
   count += 1
   n += 2 ** count
print(n)
print(h)


Failing test case input:
1011000000111

Expected output:
1099511627775


Actual output:
1099511627775
1


Fixed submission (verdict: Accepted):
h = int(input())

count = 0
n = 1
while (h > 1):
   h = int(h / 2)
   count += 1
   n += 2 ** count
print(n)

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

def fibonaci(h):
    if h <2:
        return 1
    else:
        return (2*fibonaci(h/2) + 1)


print(fibonaci(1000000000000))

Failing test case input:
1110100001001

Expected output:
2199023255551


Actual output:
1099511627775


Fixed submission (verdict: Accepted):
a = int(input())
def fibonaci(h):
    if h < 2:
        if h == 0:
            return 0
        return 1
    else:
        return (2*fibonaci(h/2) + 1)


print(fibonaci(a))

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
H=int(input())
ans = 0
print(H)
while H > 1:
    if H%2 == 0:
        H = H/2
        ans += 1
    else:
        H = (H-1)/2
        ans += 1
N = 2**ans
def fight(k):
    if k == 1:
        return 1
    else:
        return 2*fight(k/2)+1
    
        
print(fight(N))


Failing test case input:
1111000001110

Expected output:
2199023255551


Actual output:
1111000001110
2199023255551


Fixed submission (verdict: Accepted):
H=int(input())
ans = 0

while H > 1:
    if H%2 == 0:
        H = H/2
        ans += 1
    else:
        H = (H-1)/2
        ans += 1
N = 2**ans
def fight(k):
    if k == 1:
        return 1
    else:
        return 2*fight(k/2)+1
    
        
print(fight(N))

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h = int(input())
ans, i = 0, 1
while h >= i:
    ans += 1
    i *= 2
print(ans)

Failing test case input:
1010001000011

Expected output:
1099511627775


Actual output:
40


Fixed submission (verdict: Accepted):
h = int(input())
ans, i = 0, 1
while h >= i:
    ans += i
    i *= 2
print(ans)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
from math import ceil

h = int(input())

ans = 1
i = 0
while h > 1:
    i += 1
    h = ceil(h/2)
print(i)
for k in range(1, i+1):
    ans += 2**k

print(ans)


Failing test case input:
1011000000010

Expected output:
1099511627775


Actual output:
40
2199023255551


Fixed submission (verdict: Accepted):
from math import floor

h = int(input())

ans = 1
i = 0
while h != 1:
    i += 1
    h = floor(h/2)
    ans += 2**i

print(ans)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n=int(input())

for i in range(50):
    if n<2**i:
        break
print(i)

out=0
for k in range(i):
    out+=2**k

print(out)


Failing test case input:
1010100001000

Expected output:
1099511627775


Actual output:
40
1099511627775


Fixed submission (verdict: Accepted):
n=int(input())

for i in range(50):
    if n<2**i:
        break


out=0
for k in range(i):
    out+=2**k

print(out)
Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h = int(input())

ch=1
total=1

while 1:
    if h <= ch:
        break
    else:
        ch*=2
        total+=1

print(ch*2-1)

Failing test case input:
1010001000010

Expected output:
1099511627775


Actual output:
2199023255551


Fixed submission (verdict: Accepted):
h = int(input())

ch=1
total=1

while 1:
    if h < ch:
        break
    else:
        ch*=2
        total+=1

print(ch-1)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
H = int(input())

a = int(math.log(H,2))

print((2**a)-2 + (2**a))

Failing test case input:
1110000011110

Expected output:
2199023255551


Actual output:
2199023255550


Fixed submission (verdict: Accepted):
import math
H = int(input())

a = int(math.log(H,2))

print((2**(a+1))-1)

Problem: p02786
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
from math import ceil,log

h=int(input())
x =ceil(log(h, 2))
print( sum([2**y for y in range(x+1)]))


Failing test case input:
1010000001000

Expected output:
1099511627775


Actual output:
2199023255551


Fixed submission (verdict: Accepted):
import math 
 
h=int(input())
x =math.floor(math.log(h,2))
print( sum([2**y for y in range(x+1)]))

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
H = int(input())

c = 1
while H >= 2**c:
    c += 2

print(2 ** c - 1)

Failing test case input:
1010100001000

Expected output:
1099511627775


Actual output:
2199023255551


Fixed submission (verdict: Accepted):
H = int(input())

c = 1
while H >= 2**c:
    c += 1

print(2 ** c - 1)

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

H = int(input())

count = 1
while True:
    if H == 1:
        break
    H = math.ceil(H/2)
    count += 1

print(2**count-1)


Failing test case input:
1010100001000

Expected output:
1099511627775


Actual output:
2199023255551


Fixed submission (verdict: Accepted):
import math

H = int(input())

count = 1
while True:
    if H == 1:
        break
    H = math.floor(H/2)
    count += 1

print(2**count-1)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
def a(x):
    if x == 1: return 1
    if x > 1: return a(math.ceil(x/2)) * 2 + 1

print(a(int(input())))


Failing test case input:
1111000001110

Expected output:
2199023255551


Actual output:
4398046511103


Fixed submission (verdict: Accepted):
def a(x):
    if x == 1: return 1
    if x > 1: return a(x 

print(a(int(input())))

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
S=int(input())
ANS=0
if S <= 1:
  print(1)
else:
  ANS=1
  while 2**ANS <= S:
    ANS += 1
  
  print(ANS**2-1)

Failing test case input:
1011001011111

Expected output:
1099511627775


Actual output:
1599


Fixed submission (verdict: Accepted):
S=int(input())
ANS=0
if S <= 1:
  print(1)
else:
  ANS=1
  while 2**ANS <= S:
    ANS += 1
  
  print(2**ANS-1)
Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
H=int(input())
ans=1
bycount=1
count=0
byby=0
if H==1:
    ans=1
    print(ans)
while H>1:
    H=int(H/2)
    bycount+=1
    if count==0:
        count+=1
    if count>0:
        byby+=1
    if H==1:
        break

ans=1+byby*bycount
print(ans)

Failing test case input:
1010001000000

Expected output:
1099511627775


Actual output:
1561


Fixed submission (verdict: Accepted):
H=int(input())
ans=1
bycount=0
count=0
byby=0

while H>1:
    H=int(H/2)
    bycount+=1

    if H==1:
        break
while bycount!=0:
    ans+=2**bycount
    bycount=bycount-1

print(ans)

Problem: p02786
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
H = int(input())

i = 0
while True:
  if H < 2 ** i:
    n = i-1
    break
  i += 1

print(2**n -1)


  

Failing test case input:
1010000001001

Expected output:
1099511627775


Actual output:
549755813887


Fixed submission (verdict: Accepted):
H = int(input())

i = 0
while True:
  if H < 2 ** i:
    n = i
    break
  i += 1

print(2**n -1)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
def hel(h):
  if h==0:
    return 1
  else:
    return (2*hel(int(h/2))+1)
health=int(input())
print(hel(health))


Failing test case input:
1010000010000

Expected output:
1099511627775


Actual output:
2199023255551


Fixed submission (verdict: Accepted):
def hel(h):
  if h==1:
    return 1
  else:
    return (2*hel(int(h/2))+1)
health=int(input())
print(hel(health))

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
H = int(input())
s = 1
while H!=0:
    H = divmod(H, 2)[0]
    s *= 2

print(int(s / 2))


Failing test case input:
1111010001010

Expected output:
2199023255551


Actual output:
1099511627776


Fixed submission (verdict: Accepted):
H = int(input())
s = 1
while H!=0:
    H = divmod(H, 2)[0]
    s *= 2
s = s / 2
p = s - 1
print(int(s + p))

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
H = int(input())
for i in range(1, 40):
    if 2**i <= H < 2**(i+1):
        print(2**(i+1)-1)

Failing test case input:
1111000001010

Expected output:
2199023255551


Actual output:

Fixed submission (verdict: Accepted):
H = int(input())
if H==1:
    print(1)
else:
    for i in range(1, 50):
        if 2**i <= H < 2**(i+1):
            print(2**(i+1)-1)

Problem: p02786
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
h = int(input())

power = 0
while True:
  if 2**power < h:
    power += 1
  else:
    break
    
layer = power + 1
ans = int(2**layer - 1)
print(ans)

Failing test case input:
1010000000010

Expected output:
1099511627775


Actual output:
2199023255551


Fixed submission (verdict: Accepted):
h = int(input())

power = 0
while True:
  if 2**power <= h < 2**(power+1):
    break
  else:
    power += 1
    
layer = power + 1
ans = int(2**layer) - 1
print(ans)
Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
h = int(input())
cnt=0
while True:
 cnt+=1
 h=math.floor(h/2)
 if (h/2) < 1:
  cnt+=1
  break
sum=0
for i in range(cnt):
 sum=sum + (2**i)
if h == 1:
 print(1)
else:
 print(sum)

Failing test case input:
1111000001010

Expected output:
2199023255551


Actual output:
1


Fixed submission (verdict: Accepted):
import math
h = int(input())
if h == 1:
 print(1)
else:
 cnt=0
 while True:
  cnt+=1
  h=math.floor(h/2)
  if (h/2) < 1:
   cnt+=1
   break
 sum=0
 for i in range(cnt):
  sum=sum + (2**i)
 print(sum)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h = int(input())
print(h.bit_length())
print(2 ** (h.bit_length()) -1)

Failing test case input:
1010000001000

Expected output:
1099511627775


Actual output:
40
1099511627775


Fixed submission (verdict: Accepted):
h = int(input())
print(2 ** (h.bit_length()) -1)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h = int(input())

lhb = len(format(h, "b"))
print(2 * lhb  - 1)

Failing test case input:
1110100001001

Expected output:
2199023255551


Actual output:
81


Fixed submission (verdict: Accepted):
h = int(input())

lhb = len(format(h, "b"))
print(2 ** lhb  - 1)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h = int(input())

lhb = len(format(h, "b"))
print(2 ** lhb  - 1 + lhb)

Failing test case input:
1111000101110

Expected output:
2199023255551


Actual output:
2199023255592


Fixed submission (verdict: Accepted):
h = int(input())

lhb = len(format(h, "b"))
print(2 ** lhb  - 1)

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

h=int(input())
if h==1:
  print(1)
  exit(0)
tmp=math.log(h, 2)
tmp2=math.floor(tmp)
if tmp-tmp2>0:
  h=h
count=0
for i in range(h):
  p=int(math.pow(2, i))
  if h<p:break
  count+=h
print(count)


Failing test case input:
1010100001010

Expected output:
1099511627775


Actual output:
40404000040400


Fixed submission (verdict: Accepted):
import math

h=int(input())
if h==1:
  print(1)
  exit(0)
tmp=math.log(h, 2)
tmp2=math.floor(tmp)
if tmp-tmp2>0:
  h=h
count=0
for i in range(tmp2+1):
  p=int(math.pow(2, i))
  count+=p
  
print(count)

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

def fibonaci(h):
    if h == 0:
        return 0
    if h <2:
        return 1
    else:
        return (2*fibonaci(h/2) + 1)


print(fibonaci(0))

Failing test case input:
1011000000000

Expected output:
1099511627775


Actual output:
0


Fixed submission (verdict: Accepted):
a = int(input())
def fibonaci(h):
    if h < 2:
        if h == 0:
            return 0
        return 1
    else:
        return (2*fibonaci(h/2) + 1)


print(fibonaci(a))
Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
H = int(input())


def divCount(n, cnt = 0):
    if n <= 1:
        return cnt
    return divCount(n / 2, cnt + 1)

attackCount = 0
for i in range(0, divCount(H)+1):
    attackCount += pow(2, i)

print(attackCount)

Failing test case input:
1011000010111

Expected output:
1099511627775


Actual output:
2199023255551


Fixed submission (verdict: Accepted):
H = int(input())


def divCount(n, cnt = 0):
    if n <= 1:
        return cnt
    return divCount(int(n / 2), cnt + 1)

attackCount = 0
for i in range(0, divCount(H)+1):
    attackCount += pow(2, i)

print(attackCount)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
h = int(input())

print(2**(math.ceil(math.log(h,2))+1)-1)

Failing test case input:
1010001000011

Expected output:
1099511627775


Actual output:
2199023255551


Fixed submission (verdict: Accepted):
import math
h = int(input())
print(2**(math.floor(math.log(h,2))+1)-1)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h=int(input())
a=0
b=0
if h%2 != 0:
	h=h-1
c=h
while h > 1:
	h=int(h/2)
	a+=1
print(a)
for i in range(a):
	b+=2**i
print(2**a+b)

Failing test case input:
1111000000011

Expected output:
2199023255551


Actual output:
40
2199023255551


Fixed submission (verdict: Accepted):
h=int(input())
a=0
b=0
if h%2 != 0:
	h=h-1
c=h
while h > 1:
	h=int(h/2)
	a+=1

for i in range(a):
	b+=2**i
print(2**a+b)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
H = int(input()) 
atCount = 0 

nthPow = H
n = 0

while nthPow > 1:
  nthPow = int(nthPow / 2)
  n = n + 1
print(n)
print(2 ** (n + 1) - 1)

Failing test case input:
1011000000000

Expected output:
1099511627775


Actual output:
39
1099511627775


Fixed submission (verdict: Accepted):
H = int(input()) 
atCount = 0 
n = 0 


while H > 1:
  H = int(H / 2)
  n = n + 1

print(2 ** (n + 1) - 1)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a=int(input())
n = str(bin (a))
print(n,2**(len(n)-2)-1)

Failing test case input:
1010000000010

Expected output:
1099511627775


Actual output:
0b1110101100101000101100001111010000001010 1099511627775


Fixed submission (verdict: Accepted):
a=int(input())
n = str(bin (a))
print(2**(len(n)-2)-1)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
h = int(input())
k = (math.log2(h))
print((2**(k+1)-1))

Failing test case input:
1010001000010

Expected output:
1099511627775


Actual output:
2020002000018.996


Fixed submission (verdict: Accepted):
import math
h = int(input())
k = int(math.log2(h))
print((2**(k+1)-1))

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import math
H = int(input())

count = 0
count = int(math.log2(H))

total = 0
total = (1 - (2**(count + 1)))/(1 - 2)
print(total)


Failing test case input:
1010101000010

Expected output:
1099511627775


Actual output:
1099511627775.0


Fixed submission (verdict: Accepted):
import math
H = int(input())

count = 0
count = int(math.log2(H))

total = 0
total = int((1 - (2**(count + 1)))/(1 - 2))
print(total)
Problem: p02786
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
H = int(input())
now = 1
for i in range(1,100):
  if H< now:
    print(2**i-1)
    break
  else:
    now *= 2


Failing test case input:
1010000000010

Expected output:
1099511627775


Actual output:
2199023255551


Fixed submission (verdict: Accepted):
H = int(input())
now = 1
for i in range(1,100):
  if now <= H <= now*2-1:
    print(2**i-1)
    break
  else:
    now *= 2

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h=int(input())
m=0
while 2**m<=h:
    m+=1
m=m-1
print(2**m-1)


Failing test case input:
1110000011110

Expected output:
2199023255551


Actual output:
1099511627775


Fixed submission (verdict: Accepted):
h=int(input())
m=0
while 2**m<=h:
    m+=1
print(2**m-1)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
a = 0

def fibonaci(h):
    if h <2:
        return 1
    else:
        return (2*fibonaci(h/2) + 1)

a += fibonaci(10000000000)
print(a)

Failing test case input:
1010101000010

Expected output:
1099511627775


Actual output:
17179869183


Fixed submission (verdict: Accepted):
a = int(input())
def fibonaci(h):
    if h < 2:
        if h == 0:
            return 0
        return 1
    else:
        return (2*fibonaci(h/2) + 1)


print(fibonaci(a))

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

from math import log2
n=int(input())
k=round(log2(n))
if int(k)==k:
    print(pow(2,k+1)-1)
else:
    print(pow(2,k)-1)

Failing test case input:
426

Expected output:
511


Actual output:
1023


Fixed submission (verdict: Accepted):

from math import log2,floor
n=int(input())
k=floor(log2(n))
if int(k)==k:
    print(pow(2,k+1)-1)
else:
    print(pow(2,k)-1)

Problem: p02786
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
h = int(input())

import math

if h == 1:
    print(1)

else:
    n_attacks = 0
    while h / 2 > 1:
        n_attacks += 1
        h = math.floor(h/2)

    gsum = 1

    for x in range(n_attacks + 1):
        gsum += 2 ** (x + 1)
        
    print(gsum)

Failing test case input:
1011001011111

Expected output:
1099511627775


Actual output:
2199023255551


Fixed submission (verdict: Accepted):
h = int(input())

import math

if h == 1:
    print(1)

else:
    n_attacks = 0
    while h / 2 >= 1:
        n_attacks += 1
        h = math.floor(h/2)

    gsum = 1

    for x in range(n_attacks):
        gsum += 2 ** (x + 1)
        
    print(gsum)
Problem: p03780
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)

a = 0
maisu=0
ans = 0
for i in range(n):
    maisu+=1
    a += l[i]
    if a >= k:
        a = 0
        ans += maisu
        maisu = 0
print(n - ans)

Failing test case input:
3 6
1 5 2

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)

a = 0
maisu = 0
end_maisu = 0
ans = 0
for i in range(n):
    maisu += 1
    a += l[i]
    if a >= k:
        a -= l[i]
        ans += 1
        end_maisu = maisu
        maisu -= 1
end_maisu -= 1
if end_maisu < 0:
    end_maisu = 0

print(n - ans - end_maisu)

Problem: p03780
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
a = list(map(int, input().split()))

a = sorted(a)[::-1]
ans = n
sm = 0

for i in range(0, n):
    if sm + a[i] < k:
        sm += a[i];
    else:
        ans = min(ans, i);

print(ans)


Failing test case input:
3 6
2 7 2

Expected output:
2


Actual output:
0


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
a = list(map(int, input().split()))

a = sorted(a)[::-1]
ans = n
sm = 0

for i in range(n):
    if sm + a[i] < k:
        sm += a[i]
    else:
        ans = min(ans, n - i - 1)

print(ans)

Problem: p03780
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)

a = 0
maisu = 0
end_maisu = 0
ans = 0
for i in range(n):
    maisu += 1
    a += l[i]
    if a >= k:
        a -= l[i]
        ans += 1
        end_maisu = maisu
        maisu = 0
end_maisu -= 1
if end_maisu < 0:
    end_maisu = 0

print(n - ans - end_maisu)


Failing test case input:
6 20
10 4 5 10 25 3

Expected output:
0


Actual output:
1


Fixed submission (verdict: Accepted):
n, k = map(int, input().split())
l = list(map(int, input().split()))
l.sort(reverse=True)

a = 0
maisu = 0
end_maisu = 0
ans = 0
for i in range(n):
    maisu += 1
    a += l[i]
    if a >= k:
        a -= l[i]
        ans += 1
        end_maisu = maisu
        maisu -= 1
end_maisu -= 1
if end_maisu < 0:
    end_maisu = 0

print(n - ans - end_maisu)
Problem: p02662
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):

N,S=map(int,input().split())
A=list(map(int,input().split()))
mod=998244353

dp=[[0 for j in range(S+1)] for i in range(N+1)]
dp[0][0]+=1
print(dp)
for i in range(N):
    for j in range(S+1):
        dp[i+1][j]+=2*dp[i][j]
        dp[i+1][j]%=mod
        if j+A[i]<=S:
            dp[i+1][j+A[i]]+=dp[i][j]
            dp[i+1][j+A[i]]%=mod            
print(dp[N][S])

Failing test case input:
10 20
3 1 4 1 4 9 2 4 5 2

Expected output:
1600


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


Fixed submission (verdict: Accepted):

N,S=map(int,input().split())
A=list(map(int,input().split()))
mod=998244353

dp=[[0 for j in range(S+1)] for i in range(N+1)]
dp[0][0]+=1
for i in range(N):
    for j in range(S+1):
        dp[i+1][j]+=2*dp[i][j]
        dp[i+1][j]%=mod
        if j+A[i]<=S:
            dp[i+1][j+A[i]]+=dp[i][j]
            dp[i+1][j+A[i]]%=mod            
print(dp[N][S])

Problem: p02662
Buggy submission (PyPy3 (7.3.0), verdict: Wrong Answer):
n,s = map(int,input().split())
a = list(map(int,input().split()))
mod = 998244353

dp = [[0] * (s+1) for _ in range(n+1)]

dp[0][0] = 1
for i in range(1,n+1):
    for j in range(0,s+1):
        dp[i][j] += dp[i-1][j]
        if(j>=a[i-1]):
            dp[i][j] += dp[i-1][j-a[i-1]]
        dp[i][j] %= mod

print(dp[-1][-1])

Failing test case input:
10 20
5 1 7 1 1 2 2 6 5 3

Expected output:
1260


Actual output:
53


Fixed submission (verdict: Accepted):
n,s = map(int,input().split())
a = list(map(int,input().split()))
mod = 998244353

dp = [[0] * (s+1) for _ in range(n+1)]

dp[0][0] = 1
for i in range(1,n+1):
    for j in range(0,s+1):
        dp[i][j] += dp[i-1][j] * 2
        if(j>=a[i-1]):
            dp[i][j] += dp[i-1][j-a[i-1]]
        dp[i][j] %= mod

print(dp[-1][-1])
Problem: p03878
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
A=[(int(input()),"a") for i in range(N)]
B=[(int(input()),"b") for i in range(N)]
C=sorted(A+B)
mod=10**9+7
a,b=0,0
ans=1
for c in C:
  if c[1]=="a":
    if b>0:
      ans*=(ans*b)%mod
      b-=1
    else:
      a+=1
  if c[1]=="b":
    if a>0:
      ans=(ans*a)%mod
      a-=1
    else:
      b+=1
print(ans)      
    

Failing test case input:
3
1
10
8
12
0
0

Expected output:
2


Actual output:
4


Fixed submission (verdict: Accepted):
N=int(input())
C=[]
for i in range(N):
  C.append((int(input()),"a")) 
for i in range(N):
  C.append((int(input()),"b")) 
C.sort()
mod=10**9+7
a,b=0,0
ans=1
for c in C:
  if c[1]=="a":
    if b>0:
      ans=(ans*b)%mod
      b-=1
    else:
      a+=1
  if c[1]=="b":
    if a>0:
      ans=(ans*a)%mod
      a-=1
    else:
      b+=1
print(ans)

Problem: p03878
Buggy submission (PyPy3 (2.4.0), verdict: Wrong Answer):
N=int(input())
C=[]
for i in range(N):
  C.append((int(input()),"a")) 
for i in range(N):
  C.append((int(input()),"b")) 
C.sort()
mod=10**9+7
a,b=0,0
ans=1
for c in C:
  if c[1]=="a":
    if b>0:
      ans=(ans*b)%mod
      b-=1
    else:
      a+=1
  if c[1]=="b":
    if a>0:
      ans=(ans*a)%mod
      a-=1
    else:
      b+=1
  print(a,b,ans)
print(ans)      
    

Failing test case input:
2
0
4
38
408

Expected output:
2


Actual output:
1 0 1
2 0 1
1 0 2
0 0 2
2


Fixed submission (verdict: Accepted):
N=int(input())
C=[]
for i in range(N):
  C.append((int(input()),"a")) 
for i in range(N):
  C.append((int(input()),"b")) 
C.sort()
mod=10**9+7
a,b=0,0
ans=1
for c in C:
  if c[1]=="a":
    if b>0:
      ans=(ans*b)%mod
      b-=1
    else:
      a+=1
  if c[1]=="b":
    if a>0:
      ans=(ans*a)%mod
      a-=1
    else:
      b+=1
print(ans)

Problem: p03878
Buggy submission (Python (3.8.2), verdict: Wrong Answer):
def factorial(n, mod):
    ans = 1
    while not n == 0:
        ans *= n
        ans %= mod
        n -= 1
    return ans 

n = int(input())
mod = pow(10, 9) + 7
x = []
for i in range(2 * n):
    if i < n:
        x.append([int(input()), 0])
    else:
        x.append([int(input()), 1])
x.sort()
ans, cnt1, cnt2 = 1, 0, 0
for i in range(2 * n):
    cnt1 += x[i][1]
    cnt2 += 1
    if i % 2 == 1:
        if 2 * cnt1 == cnt2:
            ans *= factorial(cnt1, mod)
            ans %= mod
            cnt1, cnt2 = 0, 0
print(ans)

Failing test case input:
3
3
10
8
7
0
0

Expected output:
4


Actual output:
6


Fixed submission (verdict: Accepted):
n = int(input())
mod = pow(10, 9) + 7
x = []
for i in range(2 * n):
    if i < n:
        x.append([int(input()), 0])
    else:
        x.append([int(input()), 1])
x.sort()
ans, cnt0, cnt1 = 1, 0, 0
for i in range(2 * n):
    if x[i][1] == 0:
        if cnt1 >= 1:
            ans *= cnt1
            ans %= mod
            cnt1 -= 1
        else:
            cnt0 += 1
    else:
        if cnt0 >= 1:
            ans *= cnt0
            ans %= mod
            cnt0 -= 1
        else:
            cnt1 += 1
print(ans)
Problem: p03878
Buggy submission (Python (3.4.3), verdict: Wrong Answer):
import bisect

N = int(input())
a = []
b = []
bb = []

for i in range(N):
	a.append(int(input()))

for i in range(N):
	b.append(int(input()))

a = sorted(a)
b = sorted(b)

for i in range(N):
	bb.append(bisect.bisect_left(a, b[i]))

ans = 1
for i in range(N):
	if bb[i] - i != 0:
		ans = ans * abs(bb[i] - i)
		ans = ans % 1000000007

print(ans)

Failing test case input:
3
3
10
8
7
2
5

Expected output:
2


Actual output:
1


Fixed submission (verdict: Accepted):
import bisect

N = int(input())
a = []
b = []
bb = []

for i in range(N):
	a.append(int(input()))

for i in range(N):
	b.append(int(input()))

a = sorted(a)
b = sorted(b)

for i in range(N):
	bb.append(bisect.bisect_left(a, b[i]))

ans = 1
for i in range(N):
	if bb[i] - i != 0:
		if bb[i] > i:
			ans = ans * (bb[i] - i)
		else:
			ans = ans * (i - bb[i] + 1)
		ans = ans % 1000000007

print(ans)