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 math
h = int(input().strip())

cnt = 0
ans = 1
while True:
    if h == 1:
        break

    h = math.floor(h / 2)
    cnt += 1
    ans += 2 ** cnt
print(ans)

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

count = 1
h = H

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

print(count)

Solution (Python):

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


h = int(input())
print(atack(h))

Solution (Python):
h=int(input())
num=0
while h//2!=0:
    h//=2
    num+=1

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

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

import numpy as np

x = int(np.log2(H))
print(2 ** (x+1) - 1)

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

now = 1
cnt = 0
while now <= h:
	cnt += now
	now *= 2
print(cnt)

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

Solution (Python):
import math

H = int(input())

memo = {}

def f(n):
  if n <= 1:
    return 1
  if n in memo:
    return memo[n]
  
  memo[n] = 1 + f(math.floor(n / 2.0)) * 2
  return memo[n]

print(f(H))

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

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


i=0
s=0
while(H!=1):
    H//=2
    s+=2**i
    i+=1

s+=2**i
print(s)

Solution (Python):
H = int(input())
su = 0
ans = 0
if H == 1:
  print(1)
else:
  while not H == 1:
    H //= 2
    su += 1
  for i in range(1,su+1):
    ans += 2**i
  print(ans+1)

Solution (Python):
import math


def solve(h):
    depth = 0
    total = 0
    while h > 0:
        if h == 1:
            h = 0
        else:
            h = math.floor(h / 2)

        total += 2**depth
        depth += 1

    return total


H = int(input())
ans = solve(H)
print(ans)

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

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

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

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

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

n = 0
i = 0
while True:
    h //= 2
    n += 2**i
    i += 1
    if h == 0:
        break
print(n)

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

ex = int(math.log2(H)) + 1

print(2 ** ex - 1)

Solution (Python):
h = int(input())
d = {}

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

print(caracal(h))

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

n = 1
c = 0
while h > 1:
    h = h//2
    c += n
    n = n*2

print(n+c)

Solution (Python):
from math import log2, floor
n = int(input())
b = floor(log2(n)) + 1
print(2**b-1)

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

tmp = 1
counter = 0

while tmp <= H:
    tmp = tmp*2 
    counter += 1

print(tmp - 1)

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

Solution (Python):
import math
import numpy as np
from fractions import gcd
import fractions
import statistics
import collections
from functools import reduce
import itertools
from collections import defaultdict
import bisect
from fractions import Fraction
 
H = int(input())
A = math.log(H, 2)

ans = 0
for i in range(0,int(A)+1):
    ans += 2**i

print(ans)

Solution (Python):
import math


def highest_power_of_2(n):
    p = int(math.log(n, 2))
    return p

  
def solve(H):
    power_2 = highest_power_of_2(H)
    ans = 2 * pow(2, power_2) - 1
    print(ans)


def iin(): return int(input())

    
H = iin()
solve(H)

Solution (Python):
h = int(input())
def saiki(a):
    step = 0
    if a != 1:
        step += 1
        return  saiki(a//2) * 2 ** step
    else:
        return 1
print(saiki(h*2)-1)

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


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

print(2**t*2-1)

Solution (Python):
import math

h = int(input())

total = 0
attack = 1

while(h != 0):
    total += attack
    attack *= 2
    h = int(h/2)

print(total)

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

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

print(solve(h))

Solution (Python):
import unittest
import math


class TestD(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think(2), 3)

    def test_2(self):
        self.assertEqual(think(4), 7)

    def test_3(self):
        self.assertEqual(think(1000000000000), 1099511627775)


def solve():
    h = read()
    result = think(h)
    write(result)


def read():
    return read_int(1)[0]


def read_int(n):
    return read_type(int, n, sep=' ')


def read_float(n):
    return read_type(float, n, sep=' ')


def read_type(t, n, sep):
    return list(map(lambda x: t(x), read_line().split(sep)))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(h):
    rank = math.floor(math.log(h) / math.log(2)) + 1
    return 2 ** rank - 1


def write(result):
    print(result)


if __name__ == '__main__':
    
    solve()

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

s=bin(H)
s=s[2:]
print(2**len(s)-1)

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

ans = 0
i = 0
x = 0
while True:
    x = 2**i
    if x > h:
        break
    ans += x
    i += 1

print(ans)

Solution (Python):
H=int(input())
import math
X=math.floor(math.log2(H))
ans=0
for i in range(X+1):
  ans+=(2**i)
print(ans)

Solution (Python):
from math import log, floor

H = int(input())

a = 0
for i in range(floor(log(H, 2)) + 1):
    a += 2 ** i
print(a)

Solution (Python):
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    
    H = [int(x) for x in sys.stdin.readline().split()][0]  
    
    
    
    

    logger.debug('{}'.format([]))

    n = 0
    while (True):
        n += 1
        H = H // 2
        if H == 0:
            break

    print(sum([2**(i - 1) for i in range(1, n + 1)]))


if __name__ == "__main__":
    resolve()





import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2"""
        output = """3"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """4"""
        output = """7"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1000000000000"""
        output = """1099511627775"""
        self.assertIO(input, output)

Solution (Python):
from math import log2, floor

h = int(input())
tmp = floor(log2(h)) + 1
print(2 ** tmp - 1)

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

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

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

atc = 0
t = 0

while h != 1:
  h = h // 2
  atc += 2 ** t
  t += 1

print(atc + 2 ** t)

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

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

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

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


if __name__ == '__main__':
    main()

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

Solution (Python):
from math import floor, log2
from collections import deque

def main():
    H = int(input())
    n = floor(log2(H))
    ct = 0
    for i in range(n+1):
        ct += pow(2, i)
    print(ct)
    
    
    
    
    
    
    
    
    
    

        
    

main()

Solution (Python):
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))


H = ir()
x = 0
while True:
    if 2 ** x > H:
        break
    else:
        x += 1

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

print(answer)

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

Solution (Python):
h=int(input())
ans=1
num=1
while h!=1:
  num=num*2
  ans=ans+num
  h=h//2
print(ans)

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

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


def an(n):
    if n == 1:
        return 1
    elif n == 2 :
        return 3
    else:
        return 2 * an(n//2) + 1

print(an(h))

Solution (Python):
def solve():
    H = int(input())
    
    ans = 0
    tmp_h, n = H, 1
    while 1 < tmp_h:
        ans += n
        n *= 2
        tmp_h = tmp_h // 2
    ans += n
    print(ans)


if __name__ == '__main__':
    solve()

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

Solution (Python):
H = int(input())
H_start = H
cnt = 0
cnt_odd = 0
while H > 0:
  if H % 2 == 1:
    H -= 1

    cnt_odd += 1*2**cnt
  H = int(H/2)
  cnt += 1
print(2**cnt+H_start-cnt_odd-1)

Solution (Python):
import sys
from pprint import pprint

def solve(h):
    n = 0
    while h:
        h //= 2
        n += 1
    print(2**n-1)

if __name__ == '__main__':
    h = int(sys.stdin.readline().strip())
    solve(h)

Solution (Python):
import math
h=int(input())
s=0
i=0
while h!=0:
    s+=2**i
    h=math.floor(h/2)
    i+=1
print(s)

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

def Attack(H):
    cnt = 0
    if H == 1:
        return 1
    else:
        return (2*Attack(H//2)+1)

print(Attack(H))

Solution (Python):
from math import floor

H = int(input())

i = 0
counter = 0
while H > 0:
    H = floor(H/2)
    i += 1
    counter += (2 ** (i-1))

print(counter)

Solution (Python):
if __name__ == '__main__':
    a = int(input())
    sum = 1
    count = 0
    while a >1:
        a = a // 2
        count = count +sum
        sum = sum *2

    print(count + sum )

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

print(2**c-1)

Solution (Python):
import math
H = int(input())
if H%2==0:
  ans=0
  l=1
  while True:
    ans+=l
    H=H//2
    l*=2
    if H==0:
      print(ans);break
else:
  ans=0
  l=1
  while True:
    ans+=l
    H=math.floor(H//2)
    l*=2
    if H==0:
      print(ans);break

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

print(pow(2, n+1)-1)

Solution (Python):
import math
n = int(input())
most2n = 1
c=1
lastone = 0
while(n >= most2n):
    lastone = c
    c+=c
    most2n*=2
c = c-lastone
print(c-1+int(most2n/2))

Solution (Python):
H=int(input())
c=0
def answer(n):
  if n==1:
    return 1
  else:
    return 2*answer(n//2)+1
print(answer(H))

Solution (Python):

import bisect
h=int(input())
ans=0
l=1
cnt=0
L=[]
for i in range(41):
    L.append(2**i)

n=bisect.bisect_right(L,h)-1
ans=sum(L[:n+1])
print(ans)

Solution (Python):
h=int(input())
a=0
for i in range(h):
    a+=2**i
    h//=2
    if h==0:
        break
print(a)

Solution (Python):

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

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

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

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

count = 0
ans = 1
while H != 1:
    H = H // 2
    count += 1

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

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

print(ans)

Solution (Python):
import bisect
import numpy as np
import math
import itertools
def main():
    H = int(input())

    bin_str = format(H, 'b')
    print(int("1" * len(bin_str), 2))


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

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

Solution (Python):
H=int(input())
X=0
import math
for i in range(0,H):
  X=X+2**i
  H=math.floor(H/2)
  if H<=1/2:
    break
print(X)

Solution (Python):
from math import log2

H = int(input())
n = int(log2(H)) + 1
print(2**n - 1)

Solution (Python):
import math
import decimal
import queue
import bisect
import heapq
import time
import itertools

mod = int(1e9+7)

class Library():
    @staticmethod
    def Swap(a,b):
        return [b,a]

    @staticmethod
    def myRound(a,dig=0): 
        p = 10 ** dig
        return (a * p * 2 + 1) // 2 / p

    @staticmethod
    def Roundup(a,dig=0): 
        if a < 0:
            return int(a)
        else:
            return int(a + 0.9)

    @staticmethod
    def Gcd(a,b): 
        if (a<b):
            a,b = Library.Swap(a,b)
        if (b==0):
            return a
        else:
            return Library.Gcd(b,a%b)

    @staticmethod
    def Lcm(a,b): 
        return a//Library.Gcd(a,b)*b

    @staticmethod
    def Divisors(a): 
        divisors = []
        for i in range(1,int(a**0.5)+1):
            if a%i==0:
                divisors.append(i)
                if i!=a//i:
                    divisors.append(a//i)
        divisors.sort()
        return divisors

class Prime():
    
    
    def __init__(self,num):
        self.num = num
        self.sieve = [0] * (self.num + 1)
        self.sieve[0] = -1
        self.sieve[1] = -1
        for i in range(2,self.num + 1):
            if not self.sieve[i]:
                self.sieve[i] = i
                for j in range(i * i,self.num + 1,i):
                    if self.sieve[j]:
                        self.sieve[j] = i
    
    
    def isPrime(self,num = None):
        if num is None:
            num = self.num
        if self.sieve[num] == num:
            return True
        else:
            return False
    
    
    def PrimeNum(self,num = None):
        if num is None:
            num = self.num
        prime = []
        for i in range(2,num):
            if self.sieve[i] == i:
                prime.append(i)
        return prime
    
    
    def PrimeFact(self,num = None):
        if num is None:
            num = self.num
        fact = []
        while self.sieve[num] != num:
            fact.append(self.sieve[num])
            num //= self.sieve[num]
        fact.append(num)
        return fact

def main():
    h = int(input())
    ans = 0
    enemy = 1
    while h != 0:
        ans += enemy
        if h == 1:
            h -= 1
        else:
            h //= 2
        enemy *= 2
    print(ans)
    return

if __name__=='__main__':
    main()

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

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

Solution (Python):
import math

def main():
    H = int(input())
    x = math.log2(H)
    if(float.is_integer(x)):
        res = math.pow(2,x+1)-1
    else:
        res = math.pow(2,math.floor(x)+1)-1
    print(int(res))

if __name__ == "__main__":
    main()

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

count = 1
while h > 1:
    h = math.floor(h / 2)
    count += 1

print(2**(count)-1)

Solution (Python):
import math
def main():
    H = int(input())
    ans = 0
    
    tmp = int(math.log(H) // math.log(2))

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

if __name__ == '__main__':
    main()

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

count = 0
result = 1

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

while True:
    h = h//2
    count += 1
    result += 2**count
    if h == 1:
        break

print(result)

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

Solution (Python):
N = int(input())
j = True
b = 2
c = 0
while j:
    if b > N:
        break
    else:
        b = 2*b
        c = c + 1
    
print(2**(c+1)-1)

Solution (Python):
import sys
import math
from collections import deque
input = sys.stdin.readline
H = int(input())
n = 0
for i in range(10**3):
    if H == 1:
        break
    H //= 2
    n += 1
ans = 1
for i in range(n):
    ans *= 2
    ans += 1
print(ans)

Solution (Python):
h=int(input())
an=0
s=1

while 1:
    if h==1:
        print(an+s)
        exit()
    else:
        h=h//2
        an=an+s
        s=s*2

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

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

attack = 0
enemy_num = 1
while H > 0:
    H = H//2
    attack += enemy_num
    enemy_num *= 2
print(attack)

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

if H == 1:
  print("1")
  quit()

bin_h = str(bin(H)[2:])
len_h = len(bin_h)
ans = 2 ** len_h - 1

if bin_h[1] == 1:
  ans += 2 ** (len_h - 1)
  
print(ans)

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

monster = 1
count = 0
while H:
    H //= 2
    count += monster
    monster *= 2

print(count)

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

Solution (Python):
import math
H = int(input())
tmp = math.log2(H)
tmp2 = math.floor(tmp + 1)
result = int(2.0 ** tmp2 - 1)
print(result)

Solution (Python):
import sys
sys.setrecursionlimit(10**9)

def recur(n):
  if n==1:
    return 1
  else:
    return 2*recur(n//2)+1

H=int(input())
print(recur(H))

Solution (Python):
h = int(input())
cnt = 0
while h != 0:
    h = h//2
    cnt += 1
monster = [2**i for i in range(cnt)]
print(sum(monster))

Solution (Python):
h = int(input())
count = 1
if h == 1:
    print(count)
else:
    for i in range(10**(12)):
        h = int(h/2)
        count += 1
        if h == 1:
            break
    print(2**(count)-1)

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

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

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

while True:
    i+=1
    H//=2
    if H==0:
        break
    result+=2**i
print(result)

Solution (Python):
n = int(input())
ma = 0
ct = 0
while(n):
    if(n%2==1):
        ma =ct
    n = n//2
    ct+=1
print(2**(ma+1)-1)

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

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

count = 0
ans = 0

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

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

Solution (Python):
h=int(input())
answer=0
count=0
while h!=1:
    h=h//2
    answer+=(2**count)
    count+=1
answer+=(2**count)
print(answer)

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

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

H = int(read())

dicts = {}
cnt = 0
que = [H]
dicts[1] = 1

while len(que) != 0:
    acc = que.pop()
    if acc in dicts:
        cnt += dicts[acc]
    elif acc // 2 in dicts:
        dicts[acc] = dicts[acc // 2] * 2 + 1
        cnt += dicts[acc]
    else:
        que.append(acc // 2)
        que.append(acc // 2)
        cnt += 1

print(cnt)

Solution (Python):


H = int(input())


cnt = 0
while H != 1:
  cnt += 1
  H //= 2

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

print(ans)

Solution (Python):
def attack(h, n, total):
    if h == 1:
        return total + n
    else:
        return attack(h // 2, n * 2, total + n)

h = int(input())
print(attack(h, 1, 0))

Solution (Python):
n = int(input())
k = 0
while(n>0):
    k+=1;
    n>>=1;
print((1<<k)-1)

Solution (Python):
H = int(input())
cnt = 0
num = 1
flag = True
while flag:
    H = H // 2
    cnt += num
    if H == 0:
        flag = False
    else:
        num = num * 2
print(cnt)

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

Solution (Python):
import math

h = int(input())
x = int(math.log(h, 2))
print(2 ** (x+1) - 1)

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

Solution (Python):
import sys

H = int(input())

count = 0
index = 0
while 1:
    H = H //2
    if H==0:
        count = count + 2**index
        print(count)
        sys.exit()
    count = count + 2**index
    index = index + 1

Solution (Python):
H = int(input())
k = 0
while True:
    if pow(2,k) <= H < pow(2,k+1):
        break
    k += 1
print(pow(2,k+1)-1)

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

Solution (Python):
h=int(input())
count=0
ans=0

while h!=1:
    h//=2
    ans+=(2**count)
    count+=1

print(ans+(2**count))

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

ans=0
for i in range(int(math.log2(H))+1):
  ans+=2**i
  
print(ans)

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

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

print(ans)

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

result = 0
i = 1
while h > 0:
    h = h // 2
    result = result + i
    i *= 2

print(result)

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

n = 0
while 2**n <= h:
    n += 1

print(2**n-1)

Solution (Python):


import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

H = INT()

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

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

c = 0
while H > 0:
    H >>= 1
    c += 1

print(2**c-1)

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

result = 0
i = 1
while h > 0:
    h = h // 2
    result = result + i
    i *= 2

print(result)

Solution (Python):
h=int(input())
l=[]
x=h
ans=0
while x>0:
    l.append(x)
    x//=2
for i in range(len(l)):
    ans+=pow(2,i)

print(ans)

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

cnt = 0
attack_cnt = 0
mon_cnt = 1

while H != 1:
    H = H // 2
    mon_cnt *= 2

    cnt += 1
    attack_cnt += 2 ** (cnt - 1)


print(attack_cnt + mon_cnt)

Solution (Python):
import math
x=int(input())
k=0
s=1
while x>=1:
    x//=2
    k+=s
    s*=2
    
print(k)

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

ans = 0
cnt = 0
while 0 != H:
    H = H // 2
    ans += 2**cnt
    cnt += 1

print(ans)

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

hit = 0
n = 0
while True:
  hit += 2**n
  if hit >= h:
    break
  n += 1

print(hit)

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

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

print(cnt)

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

count = 1
while(h != 1):
    h //= 2
    count += 1

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

print(ans)

Solution (Python):
import sys

from math import log

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

def bin_pow(a,b):
    result = 1
    while b>0:
        if b&1:
            result*=a
        b>>=1
        a*=a
    return result

n = int(input())
print(bin_pow(2, int(log(n, 2))+1)-1)

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

Solution (Python):
import math

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

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

print(ans)

Solution (Python):
H = int(input())
i = 1
while True:
  i *= 2
  if H < i:
    break
print(i - 1)

Solution (Python):
from functools import lru_cache

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

    @lru_cache(maxsize=None)
    def dfs(h):
        if h <= 1:
            return 1
        else:
            return dfs(h//2) + dfs(h//2) + 1

    print(dfs(H))


if __name__ == "__main__":
    resolve()

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

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

    monster = H
    c = 0
    while monster > 0:
        c += 1
        if monster < 1:
            monster = 0
        else:
            monster = monster // 2
    ans = 0
    for i in range(c):
        ans += 2 ** i
    print(ans)

if __name__ == '__main__':
    main()

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

result = 0
i = 1
while h > 0:
    h = h // 2
    result = result + i
    i *= 2

print(result)

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

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

print(rec(H))

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

Solution (Python):

from fractions import gcd 
from functools import reduce
import sys
sys.setrecursionlimit(200000000)

def pin(type=int):
    return map(type,input().split())

H,=pin()

def crcl(num):
    if num == 1:
        return 1
        
    else:
        
        return 1+crcl(num//2)*2

print(crcl(H))

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

Solution (Python):
import math
import sys
H = int(input())

N = 1
while 1:
    if H < N:
        print(N-1)
        sys.exit()
    N *= 2

Solution (Python):
h = int(input())
cnt = 0
rest = h % 2
start = h
while h > 1:
    h //= 2
    cnt += 1

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

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

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

print(ans)

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

cnt = 1
i = 2
if h == 1:
    print(1)
else:
    while True:
        h //= 2
        cnt += i
        i *= 2
        if h == 1:
            break

    print(cnt)

Solution (Python):
H = int(input())
for i in range(60):
    if 2 ** i > H:
        print(2 ** i - 1)
        exit()

Solution (Python):
n=int(input())
cnt=0
tot=1
while n>0:
    if n==1:
        cnt+=tot
        break
    else:
        cnt+=tot
        n=n//2
        tot*=2
print(cnt)

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

h = int(input())

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

print(count(h))

Solution (Python):
H = int(input())
a = 0
cnt = 0

while a == 0:
  if H < 2**cnt:
    a = 1
  else:
    cnt += 1

print(int(2**cnt-1))

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

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

print(ans)

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

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

Solution (Python):
h = int(input())
i = 0
while 2 ** i < h:
    i += 1
print(2 ** i - 1 if 2 ** i != h else 2 ** (i + 1) - 1)

Solution (Python):



def input_one_number():
    return int(input())


givenH = input_one_number()
cnt = 0
while givenH > 0:
    cnt *= 2
    cnt += 1
    givenH //= 2

print(cnt)

Solution (Python):
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)

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

if H == 1:
    print(1)
    sys.exit(0)

ans = 0
count = 0
while H > 0:
    H = H // 2
    ans += 2**count
    count += 1

print(ans)

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

Solution (Python):
N=input()
keta=len(bin(N))-2
print 2**keta-1

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

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

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

Solution (Python):

H = int(input())

now_H = H
counter = 0
for i in range(H):
    if now_H == 1:
        break
    
    counter += 1
    now_H = now_H // 2

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

Solution (Python):

from itertools import permutations, combinations
from fractions import gcd
from collections import Counter
from math import sqrt
import sys
input = sys.stdin.readline
def lcm(x, y):
    return (x*y//gcd(x, y))
def small_letters():
    return [chr(i) for i in range(97, 97+26)]
def capital_letters():
    return [chr(i) for i in range(65, 65+26)]
def continual_letters(list_x):
    """example"""
    """[2,2,2,2,4,4,5,5,5,8,8,8,8,8] => [4,2,3,5]"""
    i,j = 0,0
    result = []
    k = len(list_x) - 1
    while(True):
        A = list_x[i]
        while(True):
            print(j)
            if list_x[j] != A:
                break
            if j >= k:
                break
            j += 1
        result.append(j-i)
        if i >= k:
            break
        i = j
    result[-1] += 1
    return result


def main():
    """ここに書いてね"""
    H = int(input())
    n = 0
    while(True):
        if H == 0:
            break
        H = H // 2
        n += 1
    print(2**n-1)

if __name__ == '__main__':
    main()

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

Solution (Python):
def main():
    H = int(input())
    div = {2**i for i in range(40)}
    ans = 0
    from math import log2, ceil
    if not(H in div):
        for h in range(int(log2(H)) + 1):
            ans += 2**h
        print(ans)
    else:
        for h in range(int(log2(H)) + 1):
            ans += 2**h
        print(ans)


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
s = [list(map(int, s.split())) for s in open(0)][0][0]
cnt = 0 
num_mon = 1
while True:
    if s > 1:
        cnt += num_mon
        s = s // 2
        num_mon += num_mon * 2 - num_mon
    else:
        break 
print(cnt + num_mon)