Problem:


Score : 400 points

Problem Statement

Caracal is fighting with a monster.

The health of the monster is H.

Caracal can attack by choosing one monster. When a monster is attacked, depending on that monster's health, the following happens:

If the monster's health is 1, it drops to 0.

If the monster's health, X, is greater than 1, that monster disappears. Then, two new monsters appear, each with the health of \lfloor X/2 \rfloor.

(\lfloor r \rfloor denotes the greatest integer not exceeding r.)

Caracal wins when the healths of all existing monsters become 0 or below.

Find the minimum number of attacks Caracal needs to make before winning.

Constraints

1 \leq H \leq 10^{12}

All values in input are integers.

Input

Input is given from Standard Input in the following format:

H

Output

Find the minimum number of attacks Caracal needs to make before winning.

Sample Input 1

2

Sample Output 1

3

When Caracal attacks the initial monster, it disappears, and two monsters appear, each with the health of 1.

Then, Caracal can attack each of these new monsters once and win with a total of three attacks.

Sample Input 2

4

Sample Output 2

7

Sample Input 3

1000000000000

Sample Output 3

1099511627775



Sample input:
2


Sample output:
3

Submission status: Wrong Answer

Solution code:
h = int(input())
print(h*2-1)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
h = 4
ans =1
while h>0:
    h = h//2
    ans*=2
ans-=1
print(ans)

Submission status: Wrong Answer

Solution code:
h = int(input())
ans =2
flag=0
while flag==0:
    h = h//2
    ans=ans**2
    if h==1:
        flag=1	
        ans//=2
        ans-=1
        print(ans)

Submission status: Wrong Answer

Solution code:
H = int(input())

from math import ceil

def test(h):
  if h >1:
    return 2*test(ceil(h/2))+1
  else:
    return 1
print(test(H))

Submission status: Wrong Answer

Solution code:
n = int(input())

ans = 1
n //= 2
i = 1
while n > 0:
    ans += i * 2
    n //= 2
    i += 1

print(ans)

Submission status: Wrong Answer

Solution code:
def f(n):
  if n==1:
    return 1
  else:
    return n*f(n//2)+1
a=int(input())
print(f(a))

Submission status: Wrong Answer

Solution code:
def calc(x):
  if x == 0:
    return 1
  return 2 * calc(x//2) + 1

h = int(input())
print(calc(h))

Submission status: Wrong Answer

Solution code:
def calc(x):
  if x == 0:
    return 1;
  return 2 * calc(x//2) + 1;

h = int(input())
print(calc(h))

Submission status: Wrong Answer

Solution code:
h = int(input())
def ans(x):
    return 2**(x)-1
count = 0
while(h>1):
    h/=2
    count+=1
print(ans(count))

Submission status: Wrong Answer

Solution code:
h = int(input())
def ans(x):
    return 2**(x+1)-1
count = 0
while(h>1):
    h/=2
    count+=1
print(ans(count))

Submission status: Wrong Answer

Solution code:
import math
 
h = float(input())
enemies = [h]
 
count = 0
while len(enemies) > 0:
  temp = []
  for enemy in enemies:
    count+=1
    if enemy > 1:
      temp.append(round(enemy / 2))
      temp.append(round(enemy / 2))
  enemies = temp
 
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = 0
while n > 1:
  n = (n + 1) // 2
  x += 1
if n==1:
  x += 1
print(2**x - 1)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = 0
while n > 1:
  n = (n + 1) // 2
  x += 1
print(2**x - 1)

Submission status: Wrong Answer

Solution code:
H = int(input())
#print(H)
# Hが2^Nのどこに該当するかを判定する*これが難しいかも。。
#H = H//2
# それがわかれば、2^N + 2^N-1 + 2^N-2 + .... 2^0の合計がわかるので、それが答え。
#print(H)
l = []
# 数学としてはわかるけれど、pythonとしてわからないというか。。

while H > 0:
  l.append(H)
  H = H//2
print(sum(l))

Submission status: Wrong Answer

Solution code:
H = int(input())
print(H)
# Hが2^Nのどこに該当するかを判定する*これが難しいかも。。
#H = H//2
# それがわかれば、2^N + 2^N-1 + 2^N-2 + .... 2^0の合計がわかるので、それが答え。
#print(H)
l = []
# 数学としてはわかるけれど、pythonとしてわからないというか。。

while H > 0:
  l.append(H)
  H = H//2
print(sum(l))

Submission status: Wrong Answer

Solution code:
import math

H = input()
m = math.ceil(math.log2(int(H)))
n = int(math.pow(2, m) - 1)
print(n)

Submission status: Wrong Answer

Solution code:
h = int(input())
res = 0
while True:
    h = int(h/2)
    res += 1
    if h == 1:
        break
    else:
        pass
print(res+1)

Submission status: Wrong Answer

Solution code:
H = int(input())
count = 0
enemy = 1
while H >= 1:
  count += enemy
  H //= 2
print(count)

Submission status: Wrong Answer

Solution code:
import math
 
h = int(input())
 
split_num = math.ceil(math.log2(h))
attack_num = sum([2**s for s in range(1, split_num+1)]) + 1
 
print(attack_num)

Submission status: Wrong Answer

Solution code:
import math

h = int(input())
 
split_num = math.floor(math.log2(h)) + 1
attack_num = sum([2**s for s in range(1, split_num+1)])
 
print(attack_num)

Submission status: Wrong Answer

Solution code:
h = int(input())
cnt = 0
if h == 1:
  print(1)
while h > 1:
  h = h // 2
  cnt += 1
print(2**(cnt+1)-1)

Submission status: Wrong Answer

Solution code:
import math
res = 0
num_enemy = 1
n = int(input())
while True:
    res += num_enemy
    if n==1:
        break
    num_enemy *= 2
    n = n//2
res

Submission status: Wrong Answer

Solution code:
hp = int(input())

count  = 0

while hp > 0:
  if hp == 1:
    hp -= 1
  else:
    hp = hp // 2
    
a = 2 ** hp -1
print(a)

Submission status: Wrong Answer

Solution code:
import math
h=int(input())
m=int(math.log(h,2))
print(int(2**(h+1)-1))

Submission status: Wrong Answer

Solution code:
h = int(input())
if h%2!=0:
    h=h-1
print(2**h-1)

Submission status: Wrong Answer

Solution code:
from math import floor	# 切り下げ
h = int(input())
cnt = 0
def attack(hp):
  if hp == 1:
    global cnt
    cnt += 1
    return
  else:
    hp = floor(hp/2)
    attack(hp)
    attack(hp)

attack(h)
print(cnt)

Submission status: Wrong Answer

Solution code:
S=int(input())
ANS=0
if S <= 1:
  print(1)
else:
  ANS=1
  while 2**ANS <= S:
    ANS += 1
  
  print(ANS**2-1)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
h = int(input())
l=1;k=2
while k<h:
  l=2*l+1
  k*=2
print(l)

Submission status: Wrong Answer

Solution code:
import math
H = int(input())
count = int((1-2**(math.log2(H)+1)) * -1)
print(count)

Submission status: Wrong Answer

Solution code:
import math
H = int(input())
a = H//2
ans = 0
for i in range(a+1):
 ans = ans + 2**i
print(ans)

Submission status: Wrong Answer

Solution code:
h = int(input())
ans = 0
while True:
    if h == 1:
        break
    elif h == 2:
        ans += 1
        break
    else:
        h //= 2
        ans += 1
print(2**ans)

Submission status: Wrong Answer

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

H = INT()

print(2**(ceil(log2(H)))-1)

Submission status: Wrong Answer

Solution code:
import math

def main():
    print(mama(1000000000000,0,0))

def mama(hp,num,sum):
    sum = sum + 2**num
    num = num + 1
    if hp <= 1:
        return sum

    hp = hp//2
    return mama(hp,num,sum)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
H = int(input())
s = 1
while H!=0:
    H = divmod(H, 2)[0]
    s *= 2

print(int(s / 2))

Submission status: Wrong Answer

Solution code:
h = int(input())
print(h * 0.9094947017737555)

Submission status: Wrong Answer

Solution code:
h = int(input())

ans = 0

for i in range(h):
    ans += 2 ** i
    h//= 2
    if h == 1:
        ans += 2 ** (i + 1)
        print(ans)
        exit()

Submission status: Wrong Answer

Solution code:

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


print(fibonaci(0))

Submission status: Wrong Answer

Solution code:

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


print(fibonaci(1000000000000))

Submission status: Wrong Answer

Solution code:
a = 0

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

a += fibonaci(10000000000)
print(a)

Submission status: Wrong Answer

Solution code:
H = int(input())

ans = 1

while H > 1:
  ans *= 2
  H /= 2
print(ans - 1)

Submission status: Wrong Answer

Solution code:
# coding utf-8
import math
H = int(input())

max_h = 10**12
n = 1

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

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

Submission status: Wrong Answer

Solution code:
# coding utf-8
import math
H = int(input())

max_h = 10**12
n = 1

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

print((2**n)-1)

Submission status: Wrong Answer

Solution code:
a=int(input())
count=0
s=1
while True:
  if a>1:
    a//=int(2)
    count+=1
    s+=2**count
  else:
    s+=2**count
    print(s)
    break

Submission status: Wrong Answer

Solution code:
a=int(input())
count=0
s=1
while True:
  if a!=1:
    a//=int(2)
    count+=1
    s+=2**count
  else:
    s+=2**count
    print(s)
    break

Submission status: Wrong Answer

Solution code:
a=int(input())
k=2
while a>k:k*=2
print(k-1)

Submission status: Wrong Answer

Solution code:
H = int(input())
d = [0]
while H > 0:
    d.append(H)
    H = H//2
d.sort()
attack = {}
attack[0] = 1
for i in range(1,len(d)):
    attack[d[i]] = 2*attack[d[i-1]] + 1
print(attack[H])

Submission status: Wrong Answer

Solution code:
def main():
    H = int(input())

    def f(x):
        if x == 1:
            return 1
        return 2 * f(x//2)

    print(f(H))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math
h = int(input())

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

Submission status: Wrong Answer

Solution code:
h = int(input())

count = 0

while h != 0:
    count += 1
    h = h//2

print(pow(2, count))

Submission status: Wrong Answer

Solution code:
H = int(input())

count = 1

while True:
    H = H//2
    count = count * 2 + 1
    if H <= 1:
        break

print(count)

Submission status: Wrong Answer

Solution code:
import math
h = int(input())
print(2**math.ceil(math.log(h,2))-1)

Submission status: Wrong Answer

Solution code:
H = int(input())


def f(n):
    if n == 1:
        return 1
    else:
        return 1 + (n // 2) * 2
print(f(H))

Submission status: Wrong Answer

Solution code:
#!/user/bin/env python
#pythonプログラムであることを示している

# -*- coding: utf-8 -*-
"""
このプログラムはPythonを書く際のテンプレとなっています。これをコピペしてコーディングを行なってください。
なお字下げしないこと！！
"""

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

import math
def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    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__':
    #上記のifの記述によってこのスクリプトファイルが起動された時だけ実行する部分になる。
    #ちなみにスクリプトが "モジュールとして"インポートされた時には実行されない、

    #単体テスト:モジュールのdocstring(ドキュメンテーション文字列)に記載された全ての対話実行例が書かれている通りに動作するかを確認
    #python ファイル名 -v
    import doctest
    doctest.testmod()

    #実際にmain()を呼び出して、結果を得て、その結果でPythonシステムを終える
    import sys
    sys.exit(main())

Submission status: Wrong Answer

Solution code:
H=int(input())
c =0

while c !=1:
 
  H = H//2
  c+=1
  
print(2**(c+1)-1)

Submission status: Wrong Answer

Solution code:
h=int(input())

def aaa(i):
    if i == 1:
        return(1)
    else:
        return 2*aaa(i//2)+1
aaa(h)

Submission status: Wrong Answer

Solution code:
h=int(input())

def aaa(i,a):
    if i == 0:
        print(a)
    else:
        a+=1
        aaa(i//2,a)
aaa(h,0)

Submission status: Wrong Answer

Solution code:
import sys
import math
sys.setrecursionlimit(10 ** 9)

def func(h,ans):
  ans += 1
  
  if h == 1:
    return ans
  if h > 1:
    return 2 * func(math.floor(h/2),ans) + 1
  
h = int(input())
ans = 0
print(func(h,ans))

Submission status: Wrong Answer

Solution code:
import math
N = int(input())

def waru2(n):
  c = 0
  while True:
    if n == 1:
      break
    n = int(n/2)
    c += 1
  return c
 
kai = 0
k = 0
while True:
  if k >= N:
    break
  k = 2 ** kai
  kai += 1

a = waru2(kai-1)

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

Submission status: Wrong Answer

Solution code:
import math
def f(x):
    if x == 1:
        return 1
    else:
        return f(math.ceil(x/2)) + f(math.ceil(x/2))
H = int(input())
print(f(H))

Submission status: Wrong Answer

Solution code:
H = int(input())
for i in range(1, 50):
    if 2**i <= H < 2**(i+1):
        print(2**(i+1)-1)

Submission status: Wrong Answer

Solution code:
H = int(input())
for i in range(1, 40):
    if 2**i <= H < 2**(i+1):
        print(2**(i+1)-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = 1
while 2**a < n:
  a+=1
if n == 1:
  print(1)
else:
  print(2**(a+1)-1)

Submission status: Wrong Answer

Solution code:
n = int(input())
if n%2 == 1:
  n -= 1
print(2**n-1)

Submission status: Wrong Answer

Solution code:
h=int(input())
m=0
while 2**m<=h:
    m+=1
m=m-1
print(2**m-1)

Submission status: Wrong Answer

Solution code:
H = int(input())
cnt = 0
while 0 < H:
  H //= 2
  cnt += 1
print(2 * cnt - 1)

Submission status: Wrong Answer

Solution code:
H = int(input())
i = 0
if H ==1:
    print(1)
else:
    while H > 1:
        H = -(- H//2)
        i += 1
    print(2**(i)-1)

Submission status: Wrong Answer

Solution code:
# -*- coding:utf-8 -*-

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

Submission status: Wrong Answer

Solution code:
import sys
from functools import lru_cache
sys.setrecursionlimit(1000000)


@lru_cache(maxsize=None)
def a(n):
    if n == 1:
        return 1
    return 1 + 2 * a(n // 2)


print(a(1000000000000))

Submission status: Wrong Answer

Solution code:
h=int(input())
i=1
while h>0:
    h//=2
    i+=1
print((1<<i)-1)

Submission status: Wrong Answer

Solution code:
H = int(input())
cnt = 0
i = 1
while H > 1:
    H = -(- H//2)
    cnt += 1
    i += 2**cnt
print(i)

Submission status: Wrong Answer

Solution code:
H = int(input())
flag = 0
while H !=1:
    if H%2 == 1:
        H+=1
    H =H/2
    flag +=1

S =0
for i in range(flag):
    S +=2**(i)

print('{}'.format(2**(flag+1)-1))

Submission status: Wrong Answer

Solution code:
H = int(input())

d=0
i=0
one = H - H%1

while(H>1):
    H = H//2
    d += 2**i
    i += 1

print(one + d)

Submission status: Wrong Answer

Solution code:
H = int(input())
i = 0
while H > 1:
    H = -(- H//2)
    i += 1
print(2**(i+1)-1)

Submission status: Wrong Answer

Solution code:

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()

Submission status: Wrong Answer

Solution code:
H = int(input())
i = 1
cnt = 0
while H > 1:
    H = -(-H//2)
    cnt += 1
    i += 2**(cnt-1) 
print(i)

Submission status: Wrong Answer

Solution code:
H = int(input())
i = 1
cnt = 0
while H > 1:
    H = -(-H//2)
    print("H=%d,i=%d" % (H,i))
    cnt += 1
    i += 2**(cnt-1) 
print(i)

Submission status: Wrong Answer

Solution code:
H = int(input())

cnt = H
B = [H]
if H == 1:
    print('0')
else:
    for i in range(100000000000):
        cnt = cnt//2
        B.append(cnt)
        if cnt == 1:
            break
        C =[1]
        for i in range(1,1001):
            C.append(C[i-1]*2)
        ans= 0
        for i in range(len(B)):
            ans +=C[i]
        print(ans)

Submission status: Wrong Answer

Solution code:
h_ = int(input())
h = h_
ans = 0
count = 1
for i in range(h):
  if h <= 1:
    print(count)
    break
  count += 1
  h = h//2

print((2 ** count)-1)
'''
if h <= 1:
  print(1)
else:
for i in range(1, h+1):
  if h <= 1:
    #ans += h_
    print(ans+1)
    break
  else:
    h = h/2
    ans += h_/h
    print(h_/h, h)
#print(ans)
'''

Submission status: Wrong Answer

Solution code:
#D
import math
i = int(input())
low = 0
high = 45
for _ in range(100):
    l = 2**low
    h = 2**high
    m = 2**((low+high)/2)
    if i < m:
        high = (low+high)/2
    else:
        low = (low+high)/2
print(low,high)
tmp = math.floor(high) + 1
print((2**tmp)-1)

Submission status: Wrong Answer

Solution code:
import math
h=int(input())
n=math.floor(math.log2(h))
x=0
for i in range(n+1):
  x+=2**i // 2^i
print(x)

Submission status: Wrong Answer

Solution code:
m=int(input())
def wow(t):
  i=0
  while(t>0):
    t=t//2
    i=i+1
  return(i)
def pow_r(x, n):
    """
    O(log n)
    """
    if n == 0:  # exit case
        return 1
    if n % 2 == 0:  # standard case ① n is even
        return pow_r(x ** 2, n // 2)
    else:  # standard case ② n is odd
        return x * pow_r(x ** 2, (n - 1) // 2)
print(wow(m))
if(m%2==0):
  print(pow_r(2,wow(m))-1)
else:
  print(pow_r(2,wow(m))-1)

Submission status: Wrong Answer

Solution code:
n = int(input())

# i = format(n, 'b')[::-1].find('1')
ans = 0
k = 1
while True:
  n //=2
  ans += k
  k *= 2
  if n <= 1:
    print(ans)
    exit()

print(ans+k)

Submission status: Wrong Answer

Solution code:
H = int(input())

cnt = 0
result = 0


def gener():
  now = 3
  while True:
    yield now
    now = now*2+1


if H == 1:
  print(1)
else:
  while True:
    if H <= 1:
      break
    cnt += 1
    H = int(H / 2)

  
  gen = gener()
  gen.__next__()

  for i in range(int(cnt)):
    if i == cnt-2:
      result = gen.__next__()
      print(result)
    else:
      gen.__next__()

Submission status: Wrong Answer

Solution code:
H = int(input())

g = int(H / 2)
ans = 0
if g == 0:
    print(1)
else:
    n = 0
    while True:
        if 2 ** (n + 1) < H:
            n += 1
        elif 2 ** (n + 1) >= H:
            n += 1
            break
    for i in range(n + 1):
        ans = ans + (2 ** i)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())

# i = format(n, 'b')[::-1].find('1')
ans = 0
k = 1
while True:
  n //=2
  ans += k
  k *= 2
  if n <= 1:
    break

print(ans+k)

Submission status: Wrong Answer

Solution code:
d = int(input())

kaisu = 0

def atack(tairyoku):
    global kaisu

    if tairyoku < 2.99999:
        return

    kaisu += 1
    atack(tairyoku/2)

atack(d)

ans = 0
def keisan(x):
    global ans
    if x <= 1:
        return
    ans += x
    keisan(int(x/2))

keisan(2**kaisu + 1)

print(ans)

Submission status: Wrong Answer

Solution code:
d = int(input())

kaisu = 0

def atack(tairyoku):
    global kaisu

    if tairyoku < 2:
        return

    kaisu += 1
    atack(tairyoku/2)

atack(d)

ans = 0
def keisan(x):
    global ans
    if x <= 1:
        return
    ans += x
    keisan(int(x/2))

keisan(2**kaisu + 1)

print(ans)

Submission status: Wrong Answer

Solution code:
d = int(input())

kaisu = 0

def atack(tairyoku):
    global kaisu

    if tairyoku < 1.999999999:
        return

    kaisu += 1
    atack(tairyoku/2)

atack(d)

ans = 0
def keisan(x):
    global ans
    if x <= 1:
        return
    ans += x
    keisan(int(x/2))

keisan(2**kaisu + 1)

print(ans)

Submission status: Wrong Answer

Solution code:
d = int(input())

kaisu = 0

def atack(tairyoku):
    global kaisu

    if tairyoku < 1.999:
        return

    kaisu += 1
    atack(tairyoku/2)

atack(d)

ans = 0
def keisan(x):
    global ans
    if x <= 1:
        return
    ans += x
    keisan(int(x/2))

keisan(2**kaisu + 1)

print(ans)

Submission status: Wrong Answer

Solution code:
import math

n = int(input())

count = 0
while(True):
  if(n==1):
    print(1)
    break
  elif(n==2):
    print(2**(count+1))
    break
  else:
    n=math.floor(n/2)
    count += 1

Submission status: Wrong Answer

Solution code:
h = int(input())

def get_tree_depth(n):
  if n <= 1:
    return 1
  else:
    return get_tree_depth(n / 2) + 1

depth = get_tree_depth(h)

print(2 ** (depth - 1) -1)

Submission status: Wrong Answer

Solution code:
import math

H = int(input())

print(bin((H << 1) - 1), 0)

Submission status: Wrong Answer

Solution code:
import math

h = int(input())

def sum(list,k):#最初から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)

Submission status: Wrong Answer

Solution code:
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)

Submission status: Wrong Answer

Solution code:
h = [int(input())]

for i in h:
    if i>1:
        j = i//2 
        h.append(j)
        h.append(j)
        
    
print(h.count(1)+1)

Submission status: Wrong Answer

Solution code:
d = int(input())

kaisu = 0

def atack(tairyoku):
    global kaisu

    if tairyoku < 1.5:
        return

    kaisu += 1
    atack(tairyoku/2)

atack(d)

ans = 0
def keisan(x):
    global ans
    if x <= 1:
        return
    ans += x
    keisan(int(x/2))

keisan(2**kaisu + 1)

print(ans)

Submission status: Wrong Answer

Solution code:
H = int(input())

cnt = 1

if H > 4:
  while H > 2:
    cnt += 1
    H = H/2

  H = 2 ** (cnt-1)

cnt = H
two = H

while two/2 > 1:
  cnt += two//2
  two = two//2

print(int(cnt+1))

Submission status: Wrong Answer

Solution code:

h = int(input())

fighting_monster_hp = h
fighting_monster_number = 1
total_attack = 0

while 1 < fighting_monster_hp:
    # 今の敵を倒す
    total_attack = total_attack + fighting_monster_number
    # 次の敵が出現
    fighting_monster_hp = fighting_monster_hp / 2
    fighting_monster_number = fighting_monster_number * 2

# 敵のHPが1になったので、今いる敵でおしまい
# h = 1000000000000で合わないのはなぜ?
if h < 1024:
    total_attack = total_attack + fighting_monster_number

print(total_attack)

Submission status: Wrong Answer

Solution code:
h = int(input())


print((2**(int(h/2)))-1)

Submission status: Wrong Answer

Solution code:
H = int(input())

times = 1

while(H>1):
  H = H/2
  times+=1

if times >10:
  times -1

print(2**times-1)

Submission status: Wrong Answer

Solution code:
import math
h = int(input())
count = 0
while (h >0):
    count +=1 
    h = math.floor(h/2)

print(1+count*(count-1))

Submission status: Wrong Answer

Solution code:
n = int(input()) 
for i in range(0,1000000000000) : 
    H = n/(2**i)
    if H <= 1 : 
        a = i 
        break 
sum = 0
if a < 40 : 
    for i in range(0,a+1) : 
        sum = sum + (2**i) 
    print(sum) 
else : 
    for i in range(0,a) : 
        sum = sum + (2**i) 
    print(sum)

Submission status: Wrong Answer

Solution code:
h = int(input())
count = 2

for i in range(100):
    if h // 2 < 1:
        count *= 2
        print(count)
        break
    else:
        h = h // 2
        count *= 2

Submission status: Wrong Answer

Solution code:
n = int(input())
flag = True
ans = 1
now = n
count = 1

for i in range(10000):
    if n > 2**i:
        pass
    elif n == 2**i:
        print(4*(2**(i)//2)-1)
        break
    else:
        print(4*(2**(i-1)//2)-1)
        break

Submission status: Wrong Answer

Solution code:
from math import ceil,log

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

Submission status: Wrong Answer

Solution code:
H = int(input())

count = 0
while H > 1:
    if H%2 == 0:
        H = H/2
    else:
        (H+1)/2
    count += 1
print(2**(count-1)+2**count)

Submission status: Wrong Answer

Solution code:

h = int(input())

fighting_monster_hp = h
fighting_monster_number = 1
total_attack = 0

while 1 < fighting_monster_hp:
    # 今の敵を倒す
    total_attack = total_attack + fighting_monster_number
    # 次の敵が出現
    fighting_monster_hp = fighting_monster_hp / 2
    fighting_monster_number = fighting_monster_number * 2

# 敵のHPが1になったので、今いる敵でおしまい
# h = 1000000000000で合わないのはなぜ?
if h < 1000000:
    total_attack = total_attack + fighting_monster_number

print(total_attack)

Submission status: Wrong Answer

Solution code:
H = int(input())

cnt = 1

while H > 2:
  cnt += 1
  H = H/2


H = 2 ** (cnt-1)

cnt = H
two = H

while two/2 > 1:
  cnt += two//2
  two = two//2

print(int(cnt+1))

Submission status: Wrong Answer

Solution code:
H = int(input())
i = 1
result = 0

if (2**38 <= H < 2**39):
    print(1099511627775)
elif (2** 37 <= H < 2**38):
    print(137438953471)
else:
    while True:
        H //= 2
        result += 2**i
        i += 1
        if H == 1:
            break
 
    print(result+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
flag = True
ans = 1
now = n
count = 1

for i in range(10000):
    if n > 2**i:
        pass
    else:
        print(4*(2**(i-1)//2)-1)
        break

Submission status: Wrong Answer

Solution code:
H = int(input())

times = 1

while(H>1):
  H = H/2
  times+=1

print(2**times-1)

Submission status: Wrong Answer

Solution code:
H = int(input())

cnt = 1

while H > 2:
  cnt += 1
  H = H/2
  print(H)

H = 2 ** (cnt-1)

print('new:', H)


cnt = H
two = H

while two/2 > 1:
  cnt += two//2
  two = two//2

print(int(cnt+1))

Submission status: Wrong Answer

Solution code:
from bisect import bisect_right
 
n=int(input())
lst=[1]
lst2=[1]
for i in range(1,41):
  lst.append(2**i)
  lst2.append(lst2[i-1]+lst[i])
  
ind=bisect_right(lst,n)
print(lst2[ind])

Submission status: Wrong Answer

Solution code:
h = int(input())

r = h//2
ans = 2**(r+1) - 1
    
print(ans)

Submission status: Wrong Answer

Solution code:

h = int(input())

fighting_monster_hp = h
fighting_monster_number = 1
total_attack = 0

while 1 < fighting_monster_hp:
    # 今の敵を倒す
    total_attack = total_attack + fighting_monster_number
    # 次の敵が出現
    fighting_monster_hp = fighting_monster_hp / 2
    fighting_monster_number = fighting_monster_number * 2

# 敵のHPが1になったので、今いる敵でおしまい
# h = 1000000000000で合わないのはなぜ?
if h < 100:
    total_attack = total_attack + fighting_monster_number

print(total_attack)

Submission status: Wrong Answer

Solution code:
n = int(input()) 
for i in range(0,1000000000000) : 
    H = n/(2**i)
    if H <= 1 : 
        a = i 
        break 
sum = 0
if a != 40 : 
    for i in range(0,a+1) : 
        sum = sum + (2**i) 
    print(sum) 
else : 
    print("1099511627775")

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
 
n=int(input())
lst=[1]
lst2=[1]
for i in range(1,41):
  lst.append(2**i)
  lst2.append(lst2[i-1]+lst[i])
  
ind=bisect_left(lst,n)
print(lst2[ind])

Submission status: Wrong Answer

Solution code:
h = int(input())
count = 2

for i in range(100):
    if h // 2 < 1:
        count * 2
        print(count)
        break
    else:
        h //= 2
        count * 2

Submission status: Wrong Answer

Solution code:
h = int(input())


print((2**(int(h/2)+1))-1)

Submission status: Wrong Answer

Solution code:
H = int(input())

count = 0

finished = False
enemies = [H]
import time
while finished == False:
    if enemies:
        if enemies[0] <= 1:
            enemies.remove(enemies[0])
            count += 1
        else:
            new_value = enemies[0] / 2

            enemies.remove(enemies[0])
            enemies = enemies + [new_value, new_value]
            count += 1
    else:
        finished = True

print(count)

Submission status: Wrong Answer

Solution code:
H = int(input())
cnt = H
while H > 1:
    cnt += H // 2
    H = H // 2
print(cnt)

Submission status: Wrong Answer

Solution code:
import sys
H = int(input())
ene = []
ene.append(H)
cnt = 0
while 1:
    tmp = int(ene[-1]/2)
    ene.pop(-1)
    if(tmp == 1):
        ene.insert(0,tmp)
        ene.insert(0,tmp)
    else:
        ene.append(tmp)
        ene.append(tmp)
    cnt += 1
    if(ene[-1] == 1):
        break
print(cnt+H)
def input():
    return sys.stdin.readline()[:-1]

Submission status: Wrong Answer

Solution code:
import math

monster_hp = int(input())
count = 0
nn = 1
nn_count = 0

while(True):
    if nn >= monster_hp:
        break
    nn *= 2
    nn_count +=1


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

Submission status: Wrong Answer

Solution code:
H = int(input())

count = 0
while H > 1:
    if H%2 == 0:
        H = H/2
    else:
        (H+1)/2
    count += 1
print(2**count+count)

Submission status: Wrong Answer

Solution code:
h = int(input())
n = 1
import math
if(h==1):
    print(h)
else:
    while(h!=1):
        h=h//2
        n=n+1
total=0
for i in range(n):
    total+=2**i
print(total)

Submission status: Wrong Answer

Solution code:
"""
if a monster is not attacked, it doesn't do anything, so we can
deal with each living monster as a separate problem that takes
a certain number of moves to kill it and all of its offspring.
when x is not 1,
num(x) = 2*num(floor(x/2))+1
(because it took one move to kill it, and there will be two offspring)
and when x is 2 or 3,
num(x) = 3
so we can do some recursion, or memoization, or tabulation
"""

from math import floor


def get_num_attacks(H):
  if H>3:
    return 2*get_num_attacks(floor(H/2))+1
  return 3


if __name__ == "__main__":
  H = int(input())
  print(get_num_attacks(H))

Submission status: Wrong Answer

Solution code:
H = int(input())
i = 1
result = 0

if (2**38 <= H < 2**39):
    print(1099511627775)
else:
    while True:
        H //= 2
        result += 2**i
        i += 1
        if H == 1:
            break
 
    print(result+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [1]

if n % 2 == 1:
    n -= 1

if n % 2 == 0:
    for i in range(int(n / 2)):
        a.append(2 * a[i])

ans = a[-1]*2 - 1

print(ans)

Submission status: Wrong Answer

Solution code:
#D
import math
i = int(input())
low = 0
high = 45
for _ in range(20):
    l = 2**low
    h = 2**high
    m = 2**((low+high)/2)
    if i < m:
        high = (low+high)/2
    else:
        low = (low+high)/2
#print(high)
if abs(math.floor(high) - high) < 10**3:
    high = math.floor(high) +1
else:
    high = math.floor(high) +1
#print(high)
tmp =high
print((2**tmp)-1)

Submission status: Wrong Answer

Solution code:
import math

H = int(input())
sum=0

n = int(math.log2(H))

for i in range(n+1):
	sum+=(int(H/2**i))
print(int(sum))

Submission status: Wrong Answer

Solution code:
h = int(input())
if h==1:
    print("1")
r=1
while h>1:
    m=h//2*2
    r+=m
    h=h//2
print(r)