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

Solution (Python):
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

h = inp()

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

print(2**cnt-1)

Solution (Python):



def attack(x):
  if x==1:
    return 1
  else:
    return 2*attack(x//2)+1
h=int(input())
print(attack(h))

Solution (Python):
from functools import lru_cache
@lru_cache(maxsize=None)
def solve(n):
    if n == 1:
        return 1
    else:
        return solve(n//2) * 2 + 1
H = int(input())
print(solve(H))

Solution (Python):
import math
print(2**int(math.log2(int(input())) + 1) - 1)

Solution (Python):

def pow(a,n):
  if n==0:
    return 1
  else:
    k=pow(a*a,n//2)
    if n%2==1:
      k=k*a
  return k

h=int(input())
cnt=0
while h>1:
  h=h//2
  cnt=cnt+1
  
print(2*pow(2,cnt)-1)

Solution (Python):
h = int(input())

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

Solution (Python):
if __name__ == '__main__':
    H = int(input())
    cnt = 0
    while H!=1:
        H //= 2
        cnt += 1
    
    ans = 0
    for c in range(cnt+1):
        ans += pow(2, c)
    
    print(ans)

Solution (Python):
import math
H = int(input())
cnt=0
next=H
while next!=1:
  next= math.floor(next/2)
  cnt +=1
result = sum([2**i for i in range(cnt+1)])
print(result)

Solution (Python):


from typing import *
import collections
import functools
import itertools
import math
import sys

INF = float('inf')


def solve(H: int):
    return 1 if H == 1 else solve(H//2) * 2 + 1


def main():

    sys.setrecursionlimit(10 ** 6)

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  
    print(f'{solve(H)}')


if __name__ == '__main__':
    main()

Solution (Python):
import math
print(2**(math.floor(math.log2(int(input())))+1)-1)

Solution (Python):
h = int(input())
ans = 1
h //= 2
i = 2
while h > 0:
    ans += i
    i *= 2
    h //= 2
print(ans)

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

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate, product 

from collections import deque,defaultdict,Counter
import decimal
import re












import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
H = I()
def monster(n):
    if n == 1:
        return 1
    return 1 + 2*(monster(n//2))
print(monster(H))

Solution (Python):
h = int(input())
cnt = 0
b = 1
while h >= 1:
    h = h//2
    cnt += b
    b *= 2

print(cnt)

Solution (Python):
H = int(input())
num = 1
ans = 0
while H > 0:
    H //= 2
    ans += num
    num *= 2
print(ans)

Solution (Python):
from math import log2

print(2**int(log2(int(input())) + 1) - 1)

Solution (Python):
def solve(n):
	if n is 0:
		return 0
	return 1 + 2 * solve(n // 2)

print(solve(int(input())))

Solution (Python):
H = int(input())

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

print(f(H))

Solution (Python):
import math

h = int(input())
n = int(math.log2(h))
 
a = 2
r = 2
S = (a*(r**n)-a) // (r-1)
print(S + 1)

Solution (Python):
import math

H = int(input())
n = int(math.log2(H))

a = 2
r = 2
S = (a*(r**n)-a) // (r-1)
print(S + 1)

Solution (Python):
def solve():
    H = int(input())
    cnt = 0
    ans = 0
    while H > 0:
        ans += 2**cnt
        if H == 1:
            break
        H = H // 2
        cnt += 1
    print(ans)


if __name__ == "__main__":
    solve()

Solution (Python):
h = int(input())
d = 0
for i in range(1000):
    if pow(2,i) <= h < pow(2,i+1):
        d = i+1
        break

print(pow(2,d)-1)

Solution (Python):
memo = {}
def f(n):
    if n==1:
        return 1
    if n in memo:
        return memo[n]
    memo[n] = 1+2*f(n//2)
    return memo[n]
print(f(int(input())))

Solution (Python):
N = int(input())
ans = 0
kotai = 1
while N >= 1:
  ans += kotai
  N = N//2
  kotai *= 2
print(ans)

Solution (Python):
import os, sys
if os.environ.get("DEBUG") is not None:
    sys.stdin = open("in.txt", "r")
rl = sys.stdin.readline

h = int(rl())
i = 1
while True:
    if h <= 2**i - 1:
        print(2**i - 1)
        break
    i += 1

Solution (Python):
H = int(input())

c=1
h=H
while 1:
    h = h//2
    if h==0 :
        break
    c+=(1+c)

print(c)

Solution (Python):
import math


def resolve():
    import sys
    input = sys.stdin.readline
    
    
    h = int(input().rstrip())

    def process(num: int):
        if num == 1:
            return 1
        else:
            count = 2 * process(num // 2)+1

        return count

    print(process(h))



if __name__ == "__main__":
    resolve()

Solution (Python):
from math import log2

n = int(log2(int(input())))

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

Solution (Python):
def ans(n,k):
  if n==0:
    return k
  else:
    return ans(n//2,k)*2+1
N=int(input())
print(ans(N,0))

Solution (Python):
def resolve():
    H = int(input())
    cnt = 0
    mons = 1
    while H != 1:
        H = H//2
        cnt += mons
        mons *= 2
    print(cnt+mons)
    
if '__main__' == __name__:
    resolve()

Solution (Python):
import math
H = int(input())
a = int(math.log2(H))
b = 2 ** a
print(b * 2 - 1)

Solution (Python):
import sys
import math

a = []
for l in sys.stdin:
    a.append(int(l))

h = a[0]
n = 0
while h > 1:
    h = math.floor(h / 2)
    n = n + 1 

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

Solution (Python):
H = int(input())
r = 0
for i in range(41):
    if H < 2**i:
        print(r)
        break
    r += 2**i

Solution (Python):
h=int(input())
hh=h
ans=1
while(1<h):
  h//=2
  ans*=2
  if h==1:
    ans+=ans

if hh==1:
  print(1)
else:
  print(ans-1)

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

Solution (Python):
import sys


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


def main():
    input = sys.stdin.buffer.readline
    h = int(input())
    print(solve(h))


if __name__ == "__main__":
    main()

Solution (Python):
import bisect

H=int(input())
A=[2**x for x in range(51)]
index=bisect.bisect_right(A,H) 
print(sum(A[:index]))

Solution (Python):
import bisect

H=int(input())
A=[2**x for x in range(51)]

if H==1:
  print(1)
elif H==2:
  print(3)
else:
  index=bisect.bisect_right(A,H) 
  print(sum(A[:index]))

Solution (Python):
h=int(input())
s=0
while h>1:
    h=h//2
    s=s+1
else:
    h=1
x=0
for i in range(s+1):
    x+=2**i
print(x)

Solution (Python):
import math 

H = int(input())

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

print(calc(H))

Solution (Python):
h = int(input())

def calc_need_atack_num(h):
    if h == 1:
        return 1
    return calc_need_atack_num(h//2) * 2 + 1

print(calc_need_atack_num(h))

Solution (Python):
H=int(input())

Q=[]
import math
for i in range(10000):
    if H>1:
        H=H//2
        Q.append(H)
    elif H==1:
        break
Q.sort()
S=0
a=1
for i in range(len(Q)):
    a=2*a+1
print(a)

Solution (Python):
def main():
    """"ここに今までのコード"""
    H = int(input())
    Count, atk = 1,1

    while H > atk * 2 - 1:
        atk = atk * 2
        Count = Count * 2 + 1
    
    print(Count)


if __name__ == '__main__':
    main()

Solution (Python):
h=int(input())
x=0
while h>0:
    x+=1
    h//=2
ans=0
tmp=1
for i in range(x):
    ans+=tmp
    tmp*=2
print(ans)

Solution (Python):
def solve():
    def beat(hp, memo):
        if hp in memo:
            return memo[hp]
        if hp == 1:
            return 1
        else:
            child_hp = hp // 2
            cnt = 1 + beat(child_hp, memo) + beat(child_hp, memo)
            memo[hp] = cnt
            return cnt

    H = int(input())
    print(beat(H, {}))

if __name__ == "__main__":
    solve()

Solution (Python):



def saiki(n):

    tmp = 0
    if n <= 1:
        return 1

    else:
        tmp = int(n/2)
        return saiki(tmp) * 2 + 1



    
h = int(input())
print(saiki(h))

Solution (Python):
H = int(input())
a = 1
an = 1
while a < H:
    a *= 2
    if a<=H:
        an += a
    else:
        break
print(an)

Solution (Python):
H = int(input())
cnt = 0
while H != 0:
    H //= 2
    cnt += 1

print(2**cnt-1)

Solution (Python):
h = int(input())

cnt = 1
ans = 0
while h:
    ans += cnt
    h //= 2
    cnt *= 2
print(ans)

Solution (Python):
H = int(input())
a = 1
i = 1
while a < H:
    a += 2 ** i
    i += 1
print(a)

Solution (Python):
N = int(input())

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

Solution (Python):
def attacks(HP, times=1):
    if HP==0: return times-1
    
    HP //= 2
    times *= 2
    return attacks(HP,times)

h=int(input())

print(attacks(h))

Solution (Python):
def attacks(HP, times=1):
    if HP==0: return times-1
    
    HP //= 2
    times *= 2
    return attacks(HP,times)

h=int(input())

print(attacks(h))

Solution (Python):
def attacks(HP, times=1):
    if HP==0: return times-1
    
    HP //= 2
    times *= 2
    return attacks(HP,times)

h=int(input())
import sys
sys.setrecursionlimit(10**5)

print(attacks(h))

Solution (Python):
import math

def caracal_vs_monster():
    """
    2**0 個                       5
           　                 /       \
    2**1 個               2.5         2.5
           　             /     \      /    \
    2**2 個           1.25   1.25  1.25   1.25
          　          /    \   /   \  /  \   /   \
    2**3 個       0.625  0.625 ...
    """
    
    H = int(input())
    
    count = int(math.log2(H))
    
    attack_count = 0
    for i in range(count+1):
        attack_count += 2 ** i
    return attack_count

result = caracal_vs_monster()
print(result)

Solution (Python):
H = int(input())
ans,attack = 1,0
while(H > 1):
  attack += 1
  H //= 2
for i in range(1,attack+1):
  ans += 2**i
print(ans)

Solution (Python):
print(int('1'*(len(str(bin(int(input()))))-2), 2))

Solution (Python):
h = int(input())
ans  = 0
count = 1
while(h>0):
  ans += count
  count *= 2
  h //= 2

print(ans)

Solution (Python):
H=int(input())
def f(H):
  if H==1:
    return 1
  elif H>1:
    return 2*f(H//2)+1
re=0
re=f(H)
print(re)

Solution (Python):
x=int(input())

v=len(bin(x))-2

print((1<<v)-1)

Solution (Python):
def main():
    h = int(input())
    ans = 1
    if h >= 1:
        i = 0
        while 2**i <= h:
            ans = 2**(i+1) - 1
            i += 1
    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):


def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def count_attack(H):
    if H == 1:
        return 1
    return 2*count_attack(H//2)+1


def solve():
    H = read_int()
    return count_attack(H)


if __name__ == '__main__':
    print(solve())

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

Solution (Python):
h = int(input())

count = 0

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

print( 2 ** count - 1 )

Solution (Python):
h = int(input())

cnt = 0
for i in range(h.bit_length()):
    cnt += 2**i
print(cnt)

Solution (Python):
n=int(input())
cnt=0
ans=0
while(n>=1):
    ans+=2**cnt
    n//=2
    cnt+=1
print(ans)

Solution (Python):
H = int(input())
p = 0
for i in range(50):
    if 2**i <= H and H < 2**(i + 1):
        p = i
        break

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

Solution (Python):
H=int(input())
X=1
while X<=H:
    X*=2
print(X-1)

Solution (Python):
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools

def aa(k):
    if k > 1: return 2*aa(k//2) + 1
    return 1

h = int(stdin.readline().rstrip())

print(aa(h))

Solution (Python):
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools

@functools.lru_cache(None)
def aa(k):
    if k > 1: return 2*aa(k//2) + 1
    return 1

h = int(stdin.readline().rstrip())

print(aa(h))

Solution (Python):
from sys import stdin
import sys
import math
from functools import reduce
import itertools

h = int(stdin.readline().rstrip())

i = 1
while True:
    h = h // 2
    if h != 0: i += 1
    if h == 0: break

print(2**i-1)

Solution (Python):
H = int(input())

def f(H):
    ans = 0
    if H > 1:
        ans += 2*f(H//2)+1
    else:
        return 1
    return ans

ans = f(H)
print(ans)

Solution (Python):
h = int( input() )

ans = 0
k = 1
while k <= h:
    ans += k
    k *= 2

print( ans )

Solution (Python):
import math
h = int(input())
num = math.log(h,2)
num = int(num)
ans = 0
for i in range(num+1):
  ans += 2**i

print(ans)

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

Solution (Python):
h = int(input())

cnt = 0
num = 1
while h!=1:
    cnt += num
    num *= 2
    h = h//2
else:
    cnt += num
print(cnt)

Solution (Python):
H=int(input())
cnt=1
ans=0
while H>0:
    H//=2
    ans+=cnt
    cnt*=2
print(ans)

Solution (Python):
from math import floor

H = int(input())

c = 1
res = 0
while H > 0:
    H = floor(H/2)
    res += c
    c <<= 1

print(res)

Solution (Python):


H = int(input())

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

ans = 0
for x in range(i):
    ans += 2 ** x
    
print(ans)

Solution (Python):
H = int(input())
c = 0
ans = 0
while H > 1:
    H = H // 2
    c += 1
for i in range(c + 1):
    ans += 2 ** i
print(ans)

Solution (Python):
n=int(input())
ans=0
while n>1:
  n=n//2
  ans+=1
  
ans1=2**(ans+1)-1
print(ans1)

Solution (Python):

import collections as cl
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    N = II()

    n = 1

    while N >= 2 ** n:
        n += 1
    print((2 ** n) - 1)


main()

Solution (Python):
from sys import stdin
input = stdin.readline


def rec(H):
  if H == 1:
    return 1
  
  return 1 + 2*rec(int(H/2))


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

  print(rec(H))


if(__name__ == '__main__'):
  main()

Solution (Python):
n=int(input())
for i in range(1,10000):
    num=2**i-1
    if n<=num:
        print(num)
        break

Solution (Python):
def check(h):
  if h > 1:
    return 2*(check(h//2))+1
  elif h==1:
    return 1
print(check(int(input())))

Solution (Python):
H = int(input())
ans = 0
attack_cnt = 0
while H > 0:
    ans += 2 ** attack_cnt
    attack_cnt += 1
    H //= 2

print(ans)

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,string
import numpy as np
import sys
sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

H = I()

sum=0
for i in range(40):
    p = pow(2,i)
    if p > H:
        n = i-1
        break
    sum += p

print(sum)

Solution (Python):
import math
h = int(input())
cnt = 0

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

ans = 0

for i in range(cnt+1):
  ans += 2 ** i

print(ans)

Solution (Python):
H = int(input())

def attack(H):
  if H == 1:
    return 1
  return 1 + attack(H // 2) * 2

print(attack(H))

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

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

Solution (Python):
H = int(input())
en = 1
at = 0

while H > 0:
  H //= 2
  at += en
  en *= 2
  
print(at)

Solution (Python):
h = int(input())

ans = 0
cnt = 1
while h > 1:
    ans += cnt
    h /= 2
    cnt = cnt * 2
if int(h) == 1:
    ans += cnt

print(ans)

Solution (Python):
H = int(input())

if H==1:
  print(1)
  exit()

i=a=0
while H >= a:
  i += 1
  a = pow(2,i)


ans = pow(2,i)-1
print(ans)

Solution (Python):
import math
H=int(input())
j=1
t=1
while H!=1:
    H=math.floor(H/2)
    t*=2
    j+=t
print(j)

Solution (Python):
H =input()

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

answer = 0
for i in range(count+1):
    answer = answer + 2 ** i
print(answer)

Solution (Python):
n1 = int(input())

n2 = 0
n3 = 1

while n1 != 0:
    n1 = n1 // 2
    n2 += n3
    n3 *= 2

print(n2)

Solution (Python):

h = int(input())

count = 0
monster = 1
while h > 0:
    h = h // 2
    count += monster
    monster *= 2

print(count)

Solution (Python):
H = int(input())

count = 0
for i in range(10**12):
    if H == 0:
        break
    H = int(H/2)
    count += 2 ** i
    

print(count)

Solution (Python):
H = int(input())

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

print(f(H))

Solution (Python):
h=int(input())
cnt=1
ans=0
while h>1:
   ans+=cnt
   cnt*=2
   h= h//2
    
print(ans+cnt)

Solution (Python):
h = int(input())
p = 1
i = 1

while h > 1:
    h = h // 2
    p += 2 ** i
    i += 1

print(p)

Solution (Python):
h=int(input())
count=1
ans=0
while h>1:
  h=h//2
  count+=1 
for i in range(1,count+1):
  ans+=2**(i-1)
print(ans)

Solution (Python):
H = int(input())

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

Solution (Python):
n = int(input())


def saiki(i):
    if i > 1:
        return 2 * saiki(i // 2) + 1
    if i == 1:
        return 1


print(saiki(n))

Solution (Python):
H = int(input())
L = len(bin(H)) - 2
ans = 0
for j in range(L):
    ans += 2 ** j
print(ans)

Solution (Python):

import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from collections import deque
from functools import lru_cache
import bisect
import re
import queue
import copy
import decimal


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [Scanner.string() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [Scanner.int() for i in range(n)]


def solve():
    N = Scanner.int()
    ans = 0
    tmp = 1
    while N > 1:
        ans += tmp
        tmp *= 2
        N //= 2
    ans += tmp
    print(ans)


def main():
    
    
    solve()


if __name__ == "__main__":
    main()

Solution (Python):
h = int(input())

counter = 0
while h > 0 :
    h //= 2
    counter += 1

print(pow(2, counter) - 1)

Solution (Python):
def func(x):
  if x==1:
    return 1
  else:
    if x%2==1:
      return func(x-1)
    else:
      return 2*func(x/2)+1
n=int(input())
print(func(n))

Solution (Python):
h = int(input())

def rc(h):
    if h == 1:
        return 1
    t = rc(h//2)*2
    return t + 1

print(rc(h))

Solution (Python):
h = int(input())
cnt = 1
while 1 < h:
    cnt += 1
    h //= 2
    


res = 0

for v in range(cnt):
    res += 2**v
print(res)

Solution (Python):
import math

H = int(input())

ans = 2 ** int(math.log2(H) + 1) - 1

print(ans)

Solution (Python):
H = int(input())

n = 1
ans = 0

while H > 0:
    ans += n
    n *= 2
    H //= 2

print(ans)

Solution (Python):

H = int(input())
cou = 1
while H>0:
    H = int(H/2)
    cou *= 2
    
print(cou-1)

Solution (Python):
import math

H = int(input())
count = 0
atk = 0
for i in range(10 ** 12):
   
    if H == 1:
        for j in range(0,atk+1):
            count += 2 ** j
        break
    else:
        H = math.floor(H / 2)
        atk += 1

print(count)

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

cnt=0
for i in range(1,100):
  if h==1:
    break
  h=math.floor(h/2)
  cnt+=2**i

print(cnt+1)

Solution (Python):
H = int(input())

def func(x):
    if x == 1:
        return 1
    return func(x//2) * 2 +1
print(func(H))

Solution (Python):
H=int(input())
ans=0
i=0
while 2**i<=H:
    ans+=2**i
    i+=1
print(ans)

Solution (Python):
def func(h):
    if h == 1:
        h = 0
        return 1
    else:
        return 1 + 2 * func(h//2)

h = int(input())
print(func(h))

Solution (Python):
H=int(input())

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

print(n_attack(H))

Solution (Python):
h = int(input())
layer = 0
branch_set = 0
while True :
    if h > 1 :
        h //= 2
        layer += 1
        continue
    else :
        break

for i in range(0, layer) :
    branch_set += 2 ** i

print(branch_set + 2**layer)

Solution (Python):
print(2**(len(bin(int(input())))-2)-1)

Solution (Python):
H = int(input())
i = len(bin(H))-2
print(2**i-1)

Solution (Python):
def f(x):
  if x==1:
    return 1
  else:
    return 2*f(x//2)+1
print(f(int(input())))

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

Solution (Python):
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

H = ri()
cnt = 1
while H > 1:
    H = H // 2
    cnt += 1
print(sum([2 ** i for i in range(cnt)]))

Solution (Python):
c= int(input())
ans =0
s = 0

while c >1:
    c = c//2
    ans += 1

for i in range(1,ans+1):
    s += 2**i

print(s+1)

Solution (Python):
H = int(input())

k = 0
while 2**k <= H:
    k += 1

print(2**k - 1)

Solution (Python):
h = int(input())
cnt = 1

while(h > 1):
  h = h // 2
  cnt += 1
  
print(2**cnt - 1)

Solution (Python):
h=int(input())


x=0
while True:
    if 2**x<=h and h<2**(x+1):
        break
    x+=1

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

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

print(2**(math.floor(math.log2(N))+1)-1)

Solution (Python):
H = int(input())
for i in range(10000):
  if 2**(i-1) <= H < 2**i:
    print(2**i-1)
    break

Solution (Python):
from math import*
print(2**ceil(log2(int(input())+1))-1)

Solution (Python):

import math
print(2**(math.ceil(math.log2(int(input())+1)))-1)

Solution (Python):
h=int(input())
def atk(n):
  if n==1:
    return 1
  return 1+2*(atk(n//2))
print(atk(h))

Solution (Python):
h=int(input())
def f(x):
  if x==1:
    return 1
  return f(x//2)*2

ans=f(h)
print(ans*2-1)

Solution (Python):
N = int(input())

ans = 0
cnt = 1
while N > 0:
    if N == 1:
        ans += cnt
        break
    N //= 2
    ans += cnt
    cnt *= 2
print(ans)

Solution (Python):
import sys
H = int(input())
if H == 1:
    print(1)
    sys.exit()
cnt = 1
i = 1
H //= 2
while H > 0:
    i <<= 1
    cnt += i
    H //= 2
print(cnt)

Solution (Python):
def attack(x):
  if x == 1:
    return 1 
  else:
    return attack(x//2) * 2 + 1

h = int(input())
print(attack(h))

Solution (Python):
from collections import deque
h=int(input())
d=dict()
def solve(h):
    if h==1:
        return 1
    else:
        l=h//2
        if l not in d.keys():
            d[l]=solve(l)
        return d[l]*2+1

print(solve(h))

Solution (Python):
from collections import deque
h = int(input())
d = dict()

def solve(h):
    if h == 1:
        return 1
    else:
        l = h // 2
        if l not in d.keys():
            d[l] = solve(l)
        return d[l] * 2 + 1

print(solve(h))

Solution (Python):
H = int(input())

res = 0
n = 1
while H > 0:
    res += n
    H //= 2
    n *= 2

print(res)

Solution (Python):
h = int(input())
c = 0
while True :
    h = h // 2
    c += 1
    if h == 0 :
        break
print(2**c-1)

Solution (Python):
import math;print(2**(int(math.log2(int(input())))+1)-1)

Solution (Python):
import math
print(2**(int(math.log2(int(input())))+1)-1)

Solution (Python):
import math
print(2**(int(math.log2(int(input())))+1)-1)

Solution (Python):
import math
print(2**(int(math.log2(int(input()))) + 1) - 1)

Solution (Python):
import sys
import math
ri = lambda: int(sys.stdin.readline())

h = ri()
a = int(math.log2(h)) + 1
print(2**a - 1)

Solution (Python):
from math import log2, ceil
H = int(input())
print(2**(ceil(log2(H))+1 if log2(H).is_integer() else ceil(log2(H))) - 1)

Solution (Python):
H=int(input())
ans = 0
count = 0
while H>0:
    H=int(H/2)
    ans+=2**count
    count+=1
print(ans)

Solution (Python):
def main4():
    n = int(input())
    m=1
    cnt = 0
    while(n>0):
        cnt += m
        n//=2
        m *= 2
    print(cnt)

if __name__ == '__main__':
    main4()

Solution (Python):
def resolve():
    H = int(input())
    ans = 1
    while H > 0:
        ans *= 2
        H //= 2
    print(ans - 1)


resolve()

Solution (Python):
h = int(input())

def hp(n):
    if n == 1:
        ans = 1
    else:
        ans = 2*hp(n//2) + 1
    return ans
print(hp(h))

Solution (Python):
n=int(input())
ans=0
m=1
while n>1:
  n=n//2
  ans+=m
  m*=2
print(ans+m)

Solution (Python):
N = int(input())

if N == 1:
    print(1)
else:
    ans = 1
    i = 1
    while N >= 2 ** i:
        ans += 2 ** i
        i += 1
    print(ans)

Solution (Python):
H = int(input())

seen = {}
seen[1] = 1

def count(n):
  if n in seen.keys():
    return seen[n]
  else:
    return 2 * count(n//2) + 1

print(count(H))

Solution (Python):
import math

h = int(input())

lg = int(math.log(h,2))

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

Solution (Python):
h=int(input())
i=h
count=1
while not i==1:
  i=int(i/2)
  count+=1
print(2**count-1)

Solution (Python):
import math

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


result = 0
for i in range(count + 1):
    result += 2**i

print(result)

Solution (Python):
h = int(input())

cnt = 0
while h:
    h //= 2
    cnt += 1

print(2**cnt-1)

Solution (Python):
H = int(input())
limit = 1000000000000
ans = 0
for i in range(limit):
    if H >= 2**i:
        ans += 2**i
    else:
        break

print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

h = int(input())

cnt = 1
ans = 0
while 0 < h:
    h //= 2
    ans += cnt
    cnt *= 2

print(ans)

Solution (Python):
H = int(input())

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

Solution (Python):

"""
Created on Fri Jul  3 23:07:58 2020

@author: Dell
"""

n=int(input())
k=1
s=0
while n>0:
    
    n//=2
    s+=k
    k*=2
print(s)

Solution (Python):
def resolve():
    h = int(input())
    c = 0
    total = 0
    while h>0:
        total += 2**c
        h = h//2
        if h == 1:
            c += 1
            total += 2**c
            break
        c += 1
    print(total)
resolve()

Solution (Python):
H = int(input())
cnt = 1

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

Solution (Python):
h = int(input())
c = 0
ans = 0
while h>1:
    h = h//2
    c += 1
ans = 2**c*2-1
print(ans)

Solution (Python):
def keisan(x):
  if x==1:
    return 1
  else:
    return 2*keisan(x//2)+1

H=int(input())
print(keisan(H))

Solution (Python):
h=int(input())
def f_h(n):
    if n==1:
        ans=1
    else:
        num=f_h(n//2)
        ans=2*num+1
    return ans
print(f_h(h))

Solution (Python):
def count_x(x):
    """
    O(logx)
    """
    if x == 1: return 1
    return 2*count_x(x//2)+1
    

print(count_x(int(input())))

Solution (Python):
h=int(input())
cnt=1
while h!=1:
  h//=2
  cnt*=2
print(2*cnt-1)

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H = int(readline())

    def dfs(h):
        if h == 1:
            return 1
        return 2 * dfs(h // 2) + 1

    print(dfs(H))
    return


if __name__ == '__main__':
    main()

Solution (Python):
import math
H = float(input())
enemy_list = [H, 1]
attack_times = 0
while (len(enemy_list) > 0):
  enemy_hp = enemy_list[0]
  enemy_num = enemy_list[1]
  attack_times += enemy_num
  if (enemy_hp == 1):
    enemy_list = []
  if (enemy_hp > 1):    
    new_enemy_hp = math.floor(enemy_hp/2)
    new_enemy_num = enemy_num * 2
    enemy_list[0] = new_enemy_hp
    enemy_list[1] = new_enemy_num
print(attack_times)

Solution (Python):
def f(H):
    if H == 1:
        return 1
    return 2 * f(H//2) + 1


def solve():
    H = int(input())
    print(f(H))


if __name__ == "__main__":
    solve()

Solution (Python):
def f(H):
    if H == 1:
        return 1
    return 2 * f(H//2) + 1


def solve():
    H = int(input())
    print(f(H))


if __name__ == "__main__":
    solve()

Solution (Python):
H = int(input())
ans = 1

i = 1
while H > 1:
    ans += 2 ** i
    H //= 2
    i += 1

print(ans)

Solution (Python):

h = int(input())

i = 1
while True:
    if 2**i > h:
        ans = 2**i-1
        break
    else:
        i += 1
print(ans)

Solution (Python):
import math

def main():
  H = float(input())
  cnt = 0
  ans = 1
  
  while H > 1:
    H = math.floor(H / 2)
    
    cnt += 1
    ans += 2 ** cnt
  
  
  print(ans)
  
main()

Solution (Python):
n = int(input())

i = 0

while n>1:
    n//=2
    i += 1

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

Solution (Python):
H = int(input())
cnt=0
ans=0
while(H>=1):
  H = int(H/2)
  ans+=pow(2,cnt)
  cnt+=1
print(ans)

Solution (Python):
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

H = i()

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

Solution (Python):
import math as m
n = int(input())
ans = (2**(int(m.log(n, 2))+1)) - 1
print(ans)