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: Accepted

Solution code:
import math
h = int(input())
ans = 0
cnt = 0
while h != 1:
    h = math.floor(h/2)
    ans += 2**cnt
    cnt += 1

print(ans+2**cnt)

Submission status: Accepted

Solution code:
h = int(input())

def func(x):
    if x <= 0:
        return 0
    if x == 1:
        return 1
    return func(x // 2) * 2 + 1

print(func(h))

Submission status: Accepted

Solution code:
import math

h = int(input())
atk = 0
for i in range(int(math.log2(h)) + 1):
    atk += 2 ** i

print(atk)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def ans(n):
    if(n==1):
        return 1
    else: return 1 + 2*ans(n//2)

a = int(input())
print(ans(a))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())
c = 1
cnt = 1
if h == 1:
  print(cnt)
  exit()
while(True):
  h=h//2
  cnt += 2**c
  if h==1:
    print(cnt)
    exit()
  else:
    c+=1

Submission status: Accepted

Solution code:
H=int(input())

i=0
ans=1
while H!=1:
    H=int(H/2)
    i+=1
    ans+=pow(2,i)
print(ans)

Submission status: Accepted

Solution code:
from math import floor, log2

def solve(n):
    return 2 ** (floor(log2(n)) + 1) - 1

_n = int(input())
print(solve(_n))

Submission status: Accepted

Solution code:
H = int(input())
num = 1
List = [1]
X = H

for i in range (H):
  if X >= 2:
  	X = X // 2
  	num = num * 2
  	List.append(num)
  else:
    break
    
print(sum(List))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import math
H = int(input())
count = 0
while math.floor(H / 2) > 0:
    H = H / 2
    count += 1
count += 1
print(-(1 - 2**count))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math


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

    # time O(log(N))
    group = math.floor(math.log(h, 2)) + 1
    ans = 2 ** group - 1
    print(ans)


main()

Submission status: Accepted

Solution code:
n = int(input())

count = 1

while True:
    if n > 1:
        n = n//2
        count += 1
    else:
        break

value = 0
factional = 0.5
for i in range(count):
    factional = factional * 2
    value += factional

print(int(value))

Submission status: Accepted

Solution code:
h=int(input())
import math
i=int(math.log2(h)-2)
while i<=int(math.log2(h))+2:
  if 2**i<=h<2**(i+1):
    print(2**(i+1)-1)
  i+=1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

n=int(input())
count = 0
sum_count = 0

while n > 0:
    if n == 1:
        n = n - 1
        sum_count = sum_count + 2**(count)
    else:
        n = math.floor(n / 2)
        count += 1
        sum_count = sum_count + 2**(count-1)

print(sum_count)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue


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 [input() 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 [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)


MOD = 998244353
INF = int(1e15)


def calc(N):
    return sum(int(x) for x in str(N))


def main():
    # sys.stdin = open("sample.txt")
    H = Scanner.int()
    ans = 0
    tmp = 1
    while H > 1:
        H //= 2
        ans += tmp
        tmp *= 2
    ans += tmp
    print(ans)
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
h = int(input())

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

Submission status: Accepted

Solution code:
h = int(input())
if h:
  count = 0
  monster = 1
  while h > 0:
    count += monster
    h //= 2
    monster *= 2
  print(count)
else:
  print(0)

Submission status: Accepted

Solution code:
# -*-coding-utf-8-*-
H = int(input())
print(2 ** (H.bit_length()) - 1)

Submission status: Accepted

Solution code:
from sys import stdin
import math
def main():
    n = int(stdin.readline().strip())
    x = int(math.log(n,2))
    print( (2**(x+1))-1)
main()

Submission status: Accepted

Solution code:

if __name__ == '__main__':
    # a = int(input())
    # a, b = map(int, input().split())

    h = int(input())
    if h == 0:
        print("0")
        exit()
    monster = 1
    count = 0
    while h > 0:
        count += monster
        h //= 2
        monster *= 2
    print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math 

H = int(input())

number1 = math.floor(math.log(H, 2))

A = 0

for i in range(number1+1):
    A += 2**i
print(A)

Submission status: Accepted

Solution code:
H = int(input())

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

ans = f(H)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

def main():
    H = int(input())
    print(2**(math.floor(math.log(H,2))+1)-1)
          
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    H = int(input())
    c = 0
    ans = 1
    while H != 1:
        H = H//2
        c += 1
        ans += 2**c
    print(ans)
          
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def calc(num):
  if num == 1:
    return 1
  else:
    return calc(num // 2)*2 + 1

print(calc(int(input())))

Submission status: Accepted

Solution code:
h = int(input())

ans = 0
cnt = 1

while h:
    ans += cnt
    cnt *= 2
    h//=2

print(ans)

Submission status: Accepted

Solution code:
from numpy import log2
h=int(input())
print(2**(int(log2(h))+1)-1)

Submission status: Accepted

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

    ans = 0
    add = 1

    while h > 0:
        ans += add
        add *= 2
        h //= 2
    print(ans)

main()

Submission status: Accepted

Solution code:
H=int(input())
t=H
k=0
while t!=0:
    t=t//2
    
    k=k+1
print(2**k-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())

import math

def A(n):
    if n > 1:
        return A(math.floor(n/2))*2+1
    else:
        return 1

print(A(H))

Submission status: Accepted

Solution code:
import sys
h = int(input())
if h == 1:
    print(1)
    sys.exit(0)

cnt = 0
while h > 1:
    h = h//2
    cnt+=1
s = 0
for i in range(cnt+1):
    s += 2**i
print(s)

Submission status: Accepted

Solution code:
a = int(input())

def f(n):
    sum = 0
    if (n == 1):
        return 1
    else:
        sum += f(int(n/2)) * 2 + 1
        return sum

print(f(a))

Submission status: Accepted

Solution code:
h = int(input())
i = 0
ans = 0

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

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

print(ans)

Submission status: Accepted

Solution code:
h = int(input())

import math
i = 0
ans = 0
while h >= 1:
    h = math.floor(h / 2)
    ans += 2 ** i
    i += 1

print(ans)

Submission status: Accepted

Solution code:
from math import floor
import sys
sys.setrecursionlimit(10000000)
 
h = int(input())
 
def f(n):
    if n == 1:
        return 1
    else:
        return f(floor(n/2)) * 2 + 1
 
print(f(h))

Submission status: Accepted

Solution code:
from math import floor
import sys
sys.setrecursionlimit(1000)
 
h = int(input())
 
def f(n):
    if n == 1:
        return 1
    else:
        return f(floor(n/2)) * 2 + 1
 
print(f(h))

Submission status: Accepted

Solution code:
H = int(input())
count = 0
i = 0
while True:
  if H == 1:
    count += 2**i
    break
  else:
    H = H//2
    count += 2**i
    i += 1
    continue
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def rec_count(num):
    if num == 1:
        return 1
    elif num == 2:
        return 3
    elif num == 3:
        return 3
    else:
        split = num // 2
        return 1 + 2 * rec_count(split)

h = int(input())
print(rec_count(h))

Submission status: Accepted

Solution code:
import math

H = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
h = int(input())
n = 100
for i in range(100):
    if pow(2,i) <= h < pow(2,i+1):
        print(pow(2,i) + pow(2,i)- 1)
        break
    
    elif h == pow(2, i+1):
        print(pow(2, i+1) + pow(2,i+1) - 1)
        break
    
    else:
        continue

Submission status: Accepted

Solution code:
# abc 153
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)

H = int(read().strip())

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

answer = solve(H)
print(answer)

Submission status: Accepted

Solution code:
import math

H_point = int(input())
t = math.floor(math.log2(H_point))
t = 2**(t+1)-1
print(t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())
r = 0
while True:
    if 2**r > h:
        break
    r += 1
print((2**r)-1)

Submission status: Accepted

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

def atakku(h, c):
  c += 1
  if h != 1:
    hh = math.floor(h / 2)
    c = atakku(hh, c*2)
  return c

N = atakku(H, 0)
print(N)

Submission status: Accepted

Solution code:
H = int(input()) # 初めのモンスターのヒットポイント
atCount = 0 # 攻撃回数
n = 0 # 指数

# ２の何乗に近い数字かを計算
while H > 1:
  H = int(H / 2)
  n = n + 1

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

Submission status: Accepted

Solution code:
import sys
#import bisect
input = sys.stdin.buffer.readline
#lb = bisect.bisect_left

def main():
	#N,K=map(int,input().split())
	#vA=list(map(int, input().split()))
	#INF = 1001001001
	H=int(input())
	
	res = 0
	en = 1
	while H:
		res += en
		H //= 2
		en *= 2

	print(res)

main()

Submission status: Accepted

Solution code:
h=int(input())
ans=0
p=0
while h:
	h//=2
	ans+=2**p
	p+=1
print(ans)

Submission status: Accepted

Solution code:
from math import log

H=int(input())

h=int(log(H,2))

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

Submission status: Accepted

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

def func_ans(x):
  sum = 0
  if x == 1:
    return 1
  else:
    return func_ans(x//2) + func_ans(x//2) + 1

ans = 0

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


#print(func_ans(h))

Submission status: Accepted

Solution code:
H = int(input())
ans = 1
H //= 2
i = 1

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


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


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    h = I()
    k = h.bit_length()
    print((1 << k) - 1)
    return


# Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
h = int(input())

count = 0
while(True):
    if h == 1:
        break
    h = h // 2
    count += 1

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

print(ans)

Submission status: Accepted

Solution code:
#abc 153
h = int(input())
t = 0
while h > 0:
    h = h//2
    t += 1
print(2**t-1)

Submission status: Accepted

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

pow = 1
res = 0
while (h!=1):
    h=math.floor(h/2)
    pow+=1
for i in range(pow):
    res += 2**i
print(res)

Submission status: Accepted

Solution code:
import math
N=int(input())
A=0
n=int(math.log2(N))
for i in range(n+1):
    A+=2**i
print(A)

Submission status: Accepted

Solution code:
[H]=list(map(int, input().split()))

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

Submission status: Accepted

Solution code:
H = int(input())
x = 0
list_1 = []
for i in range(H+1):
    if H == 1:
        list_1.append(x)
        break
    else:
        H = H // 2
        list_1.append(x)
        x += 1
list_2 = list(map(lambda a: 2**a,list_1))
print(sum(list_2))

Submission status: Accepted

Solution code:
def main():
	H = int(input())
	cnt = 0
	if H==1:
		print(1)
		exit()
	while 1:
		if H==1:
			break
		else:
			H = H//2
			cnt += 1
	ans = 0
	for i in range(cnt):
		ans += 2**i
	ans += 2**(i+1)
	print(ans)

if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
n = int(input())
m = 1
while n > m:
  m *= 2
  m += 1
print(m)

Submission status: Accepted

Solution code:
H = int(input())

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

Submission status: Accepted

Solution code:
from collections import deque
def son(generation,life):
    if life > 1:
        nextson = (generation+1, life//2)
    else:
        nextson = (0, 0)
    return nextson
    
def generationnum(generation):
    return 2**generation

def bfs(startlife,startgeneration):
    queue = deque([(startgeneration,startlife)])
    totalnum = 0
    while queue:
        label = queue.popleft()
        if label == (0, 0):
            break
        totalnum += generationnum(label[0])
        queue.append(son(label[0],label[1]))
    return totalnum
            
if __name__ == '__main__':
    print(bfs(int(input()), 0))

Submission status: Accepted

Solution code:
h = int(input())
bl = len(str(bin(h)))-2
ans = 0
for i in range(bl):
  ans += 2**i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())
 
def attackCount(hitpoint):
    if hitpoint == 1:
        return 1
    elif hitpoint > 1:
        return 2*attackCount(hitpoint//2)+1
    else:
        raise ValueError
 
 
print(attackCount(H))

Submission status: Accepted

Solution code:
import math

h = int(input())

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

print(2**count*2-1)

Submission status: Accepted

Solution code:
H = int(input())

num = 1
res = 1

if H > 1:
    while (num * 2) <= H:
        num = num * 2
        res = num * 2 - 1

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())
c = 0
while h > 0:
    h //= 2
    c += 1

print(pow(2, c)-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def hoge(n, cnt=0):
    if n == 0:
        return cnt
    else:
        return hoge(int(n/2), 2 * cnt + 1)
      
def one_int():
    return int(input())
  
  
print(hoge(one_int()))

Submission status: Accepted

Solution code:

H = int(input())


def attackCount(hitpoint):
    if hitpoint == 1:
        return 1
    elif hitpoint > 1:
        return 2*attackCount(hitpoint//2)+1
    else:
        raise ValueError


print(attackCount(H))

Submission status: Accepted

Solution code:
import sys
from math import floor, log2

# sys.stdin = open('input.txt', 'r')

h = int(input())
power = int(floor(log2(h))) + 1
print((1 << power) - 1)

Submission status: Accepted

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

print(2**n-1)

Submission status: Accepted

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

h = int(input())

print(calc(h))

Submission status: Accepted

Solution code:
def input_int():
    return int(input())

def suss(num):
  result = 2
  while num > 1:
    num = num // 2
    result = result * 2
  return result - 1

h = input_int()
print(suss(h))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def find_minimum_attack_time(health):
    if health == 1:
        return 1
    return 2 * find_minimum_attack_time(health // 2) + 1


if __name__ == '__main__':
    print(find_minimum_attack_time(int(input())))

Submission status: Accepted

Solution code:
import math

h = int(input())

c = 0

def attack_n(x):
    if x == 1:
        return 1
    
    else:
        return attack_n(int(math.floor(x/2))) *2+1

print(attack_n(h))

Submission status: Accepted

Solution code:
h = int(input())


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


print(dfs(h))

Submission status: Accepted

Solution code:
def func(H):
    if H == 1:
        return 1
    else:
        return 1+2*func(H//2)
H = int(input())
print(func(H))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H=int(input())
num=0
X=H
while True:
  X=X//2
  num+=1
  if X==0:
    break
print(2**num -1)

Submission status: Accepted

Solution code:
H = int(input())

div_num = 0
attack_num = 0
if H == 1:
	print("1")
else:
	while True:
		H = H // 2
		attack_num += 1
		if H == 1:
			break
	
	print(sum([2**i for i in range(attack_num+1)]))

Submission status: Accepted

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

Submission status: Accepted

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

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

n1 = 2 ** k - 1
n2 = 2 ** k

n = n1 + n2

print(n)

Submission status: Accepted

Solution code:
H = int(input())

def atk(h):
    if h > 1:
        return 1+atk(h//2)*2
    else:
        return 1

print(atk(H))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())
counter = 1

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

Submission status: Accepted

Solution code:
import math
def count_attack(k):
  if k==1:
    return 1
  else:
    return 2*count_attack(math.floor(k/2)) +1
h = int(input())
print(count_attack(h))

Submission status: Accepted

Solution code:
h = int(input())
def Count(a):
  if a==1:
    return 1
  return 1+2*Count(a//2)
print(Count(h))

Submission status: Accepted

Solution code:
h, = (int(x) for x in input().split())

n = len(format(h, 'b'))
k = '1'
for i in range(n):
    k += '0'

print(int(k, 2) - 1)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

# 体力
h = int(input())

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

print((2 ** i) - 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def rec(n):
  if n==1:
    return 1
  return rec(n//2)*2+1


H = int(input())
I = rec(H)
print(I)

Submission status: Accepted

Solution code:
H = int(input())
from math import floor
total = 0
counter = 1
while H > 0:
  H = floor(H/2)
  total += counter
  counter *= 2
print(total)

Submission status: Accepted

Solution code:
import math

H = int(input())

ans, mul = 0, 1
while H > 1:
    H = math.floor(H / 2)
    ans += mul
    mul *= 2

print(ans + mul)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
H = int(input())
import math
K = int(math.log2(H))
print(2 ** (K+1) - 1)

Submission status: Accepted

Solution code:
H = input()
H = int(H)
count = 0
q = H
while q != 1:
  q = int(q/2)
  count += 1

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

Submission status: Accepted

Solution code:
import math

N = int(input().strip())
cnt = 1
while N>1:
  N = math.floor(N/2)
  cnt += 1

print(int(math.pow(2,cnt)-1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))

INF = 1 << 29

DIV = (10**9) + 7

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)

def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max,mod=DIV):
    fac,finv,inv = [0]*max, [0]*max, [0]*max
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod -inv[mod%i] * (mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
    class CONV:
        def __init__(self):
            pass
        def ncr(self,n,k):
            if(n<k):
                return 0
            if(n<0 or k<0 ):
                return 0
            return fac[n]*(finv[k]*finv[n-k]%mod)%mod
    return CONV()

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

def main():
    return killTime(iRaw())


if __name__ == "__main__":
    print(main())

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

import math

H=int(input())
A=2**(math.floor(math.log(H,2)))
print(A+A-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h=int(input())
ans=0
d=1
while h!=0:
    ans+=d
    h//=2
    d*=2
print(ans)

Submission status: Accepted

Solution code:
# ABC153
# D
import math

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    h = I()
    def f(i):
        if i < 1:
            return 0
        return f(i//2) * 2 + 1

    return f(h)


print(main())

Submission status: Accepted

Solution code:
import math

H = int(input())

print(int(math.pow(2, int(math.log2(H)) +1) - 1))

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
import math


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

Submission status: Accepted

Solution code:
import math

h = int(input())
n = math.floor(math.log2(h)) + 1
print(2 ** n - 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())
def solve(X):
    if X == 1:
        return 1
    else:
        return 1 + 2 * solve(X // 2)
ANS = solve(H)
print(ANS)

Submission status: Accepted

Solution code:
h = int(input())

depth = 0
end = 2
while h >= end:
    depth += 1
    end *= 2

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

Submission status: Accepted

Solution code:
# coding: utf-8
import sys
import math

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
h = int(input())

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

Submission status: Accepted

Solution code:
H = int(input())
import math
s = 0
a = 2
for i in range(int(math.log2(H))):
    s += a
    a *= 2

print(s + 1)

Submission status: Accepted

Solution code:
def wczytaj_liste():
    ciag = input()
    rozdzielona_lista = ciag.split()
    odp = []
    for wyraz in rozdzielona_lista:
        liczba = int(wyraz)
        odp.append(liczba)
    return odp

def D():
    H = wczytaj_liste()[0]
    wykladnik = 0
    while 2**wykladnik <= H:
        wykladnik += 1
    odp = 2**wykladnik - 1
    print(odp)

D()

Submission status: Accepted

Solution code:
from math import floor
H = int(input())
tmp=1
ans=0
while H>0:
  H = floor(H/2)
  ans+=tmp
  tmp*=2
print(ans)

Submission status: Accepted

Solution code:
H = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())
cnt = 1
mul = 1
while True:
    if h == 1:
        break
    h = h // 2
    mul *= 2
    cnt += mul
print(cnt)

Submission status: Accepted

Solution code:
h = int(input())
cur = 0
for i in range(100):
  if 2**i > h:
    cur = i
    break
print(2**i-1)

Submission status: Accepted

Solution code:
import sys
import math

h = int(sys.stdin.readline())
count=0

flr = int(math.log(h,2))
for i in range(flr+1):
  count+=2**i
print(count)

Submission status: Accepted

Solution code:
H = int(input())
M = 1
A = 0
while not H == 0:
    H = int(H/2)
    A += M
    M *= 2
print(A)