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:
# -*- coding: utf-8 -*-

import sys
import math

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
#        for line in sys.stdin:
#            lines.append(line)
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]
    


    h = int(lines[0])

    return (h, )

def solve(h, ):

    current_h = h
    total_count = 1
    current_count = 1
    while True:
        
        if current_h == 1:
            break

        current_h = current_h // 2
        current_count = 2 * current_count
        total_count = total_count + current_count


    result = total_count 

    return result

def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r)
    else:
        print("%s" % result)

if __name__ == '__main__':

    main()

Submission status: Accepted

Solution code:
import collections
import itertools as it
import math
import numpy as np

# A = input()
# A = int(input())
# A = map(int, input().split())
# A = list(map(int, input().split()))
# A = [int(input()) for i in range(N)]
#
# c = collections.Counter()

H = int(input())

c = 0
for i in range(10000000):
    c += 1
    if H == 1:
        break
    else:
        H = H // 2

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

print(ans)

Submission status: Accepted

Solution code:
import math
h=int(input())
a=0
while h>1:
    h = math.floor(h/2)
    a+=1
print(sum([2**i for i in range(a+1)]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())
cnt=0
while h>0:

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

Submission status: Accepted

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

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

while(1):
    if h >= 2**(i+1) and h < 2**(i+2):
        print(2**(i+2)-1)
        exit(0)

    i = i + 1

Submission status: Accepted

Solution code:
import math
H=int(input())
count=0
i=0
while H!=0:
    H=math.floor(H/2)
    count+=2**i
    i+=1
print(count)

Submission status: Accepted

Solution code:
h = int(input())

ans = 0
i = 1
while(h != 0):
    if h != 1:
        h = int(h/2)
    else:
        h = 0
    ans +=  i
    i *= 2
print(ans)

Submission status: Accepted

Solution code:
from math import log,floor 
H=int(input())
print(2**(floor(log(H,2))+1)-1)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline
H = int(input())

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

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

Submission status: Accepted

Solution code:
from math import floor
from collections import deque

h = int(input())
cnt = 0

while True:
    if h == 1:
        break

    h //= 2
    cnt +=1

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    h=int(input())
    p=0
    n=0
    while h > 0:
        n+=2**p
        p+=1
        h>>=1
    print(n)

main()

Submission status: Accepted

Solution code:
import math
x = int(input())
n = int(math.floor(math.log2(x)))
print(pow(2,(n + 1)) - 1)

Submission status: Accepted

Solution code:
h = int(input())

bin_h = bin(h)
bin_h = bin_h[:2] + bin_h[2:].replace("0", "1")
print(int(bin_h, 2))

Submission status: Accepted

Solution code:
h = int(input())

def attack(h, memo):
    if h == 1:
        return 1
    if h in memo:
        return memo[h]
    count = 1 + 2 * attack(h // 2, memo)
    memo[h] = count
    return count

memo = {}
print(attack(h, memo))

Submission status: Accepted

Solution code:
n=int(input())

def count_attack(hp):
    count = 0        
    if hp == 2 or hp == 3:
        return 3
    else:
        # calculate new hp
        count += 1
        hp_child = hp //2
        count += 2 * count_attack(hp_child)
        return count

if n == 1:
    print(1)
else:
    print(count_attack(n))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())
d = [] # 2の累乗のまとめ
ruijou = 1
while H >= ruijou:
  d.append(ruijou)
  ruijou *= 2
print(sum(d))

Submission status: Accepted

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


class Dp:

    def __init__(self, size):
        self.size = size

    @lru_cache(maxsize=None)
    def calc(self, n):
        if n == 1:
            return 1
        return self.calc(n//2) * 2 + 1


def main():
    h = int(input())
    dp = Dp(h)
    result = dp.calc(h)
    print(result)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

h = int(input())
n = 0
i = 1
while h > 0:
    #print(h, i, n)
    h = h // 2
    n += i
    i *= 2

print(n)

Submission status: Accepted

Solution code:
H = int(input())

ans = 1

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

while True:
    tmp = ans*2 + 1
    if H > ans and H <= tmp:
        print(tmp)
        exit()
    else:
        ans = tmp

Submission status: Accepted

Solution code:
import math

H = int(input())

depth=0

while H>=1:
	depth+=1
	H=math.floor(H/2)
  
num = sum([2**i for i in range(depth)])

print(num)

Submission status: Accepted

Solution code:
N = int(input())

i = 0
sol=1
while N>1:
  N=N//2
  i+=1
  sol+=2**i
#  print(sol)

  
#sol+=2**i
#for j in range(i)+1
#   sol +=2**j

print( sol )

Submission status: Accepted

Solution code:
import math

def main():
    h = int(input())
    n = math.floor(math.log(h,2))
    print(2**(n+1)-1)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from functools import lru_cache
h=int(input())
cnt=0

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

print(func(h))

Submission status: Accepted

Solution code:
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

H = iin()

a = int(math.log(H,2))+1
print(2**a-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
H = int(input())
count = 0
ans = 0

while H!=0:
    count += 1
    H = math.floor(H/2)

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

print(ans)

Submission status: Accepted

Solution code:
H=int(input())
h=H//2
a=1
b=1
c=1
for i in range(H):
    if h==1:
        break
    if h==0:
        break
    h=h//2
    a+=1
for i in range(a):
    c=2*c
    b=b+c
if H>1:
    print(b)
else:
    print(1)

Submission status: Accepted

Solution code:
H = int(input())

for i in range(100000000): #とりあえず大きい数字
    if(2**i<=H and H<2**(i+1)):
        print(2**(i+1)-1)
        break

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Jan 19 20:52:57 2020

@author: over-
"""


H=int(input())

N=1
c=1
while(H>1):
    H=H//2
    c*=2
    N+=c

print(N)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())

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

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

Submission status: Accepted

Solution code:
H = int(input())

cnt = 1
ans = 1

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

print(ans)

Submission status: Accepted

Solution code:
# 体力
H = int(input())

def action(H, cnt):
    cnt +=1
    #print(cnt)
    if H==1:
        return cnt
    else:
        cnt = action(H//2, cnt*2)
        return cnt

cnt = action(H, 0)
print(cnt)

Submission status: Accepted

Solution code:
H = int(input())
counter = 0
pv = [1,H]
while pv[1] >1:
  counter += pv[0]
  pv[0] *=2
  pv[1] = pv[1]//2
print(counter+pv[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())

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

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

#print(count)
print(ans)

Submission status: Accepted

Solution code:
import math
n = int(input())
k = math.log(n, 2) + 1
print(2**math.floor(k)-1)

Submission status: Accepted

Solution code:
H = int(input())

# nが0になるまで何回割れるか
def divCount(n, cnt = 0):
    if n <= 1:
        return cnt
    return divCount(int(n / 2), cnt + 1)

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

print(attackCount)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

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

Submission status: Accepted

Solution code:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

import pdb
import sys
sys.setrecursionlimit(10**7)
F = sys.stdin

H = int(F.readline().rstrip())


def power(a,b):
    if b == 0:
        return 1
    elif b == 1:
        return a
    elif b%2 == 0:
        return power(a,b//2)**2
    else:
        return power(a,b//2)**2*a

ans = 0
i = 0
while power(2, i) <= H:
    ans += power(2, i)
    i += 1



print(ans)

Submission status: Accepted

Solution code:
import math
H = int(input())
lo = math.floor(math.log2(H)) + 1
cnt = 0
for i in range(lo):
    cnt += 2**i
print(cnt)

Submission status: Accepted

Solution code:
# coding: utf-8
import math

h = int(input())

n = int(math.log2(h))

total = 0

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

Submission status: Accepted

Solution code:
H = int(input())
b = H
ans = 0
for i in range(H):
  if(b//2 > 0):
    b = b // 2
    ans += 2**i
  else:
    ans += 2**i
    break
print(ans)

Submission status: Accepted

Solution code:
H = int(input())

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

Submission status: Accepted

Solution code:
h = int(input())

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

    if h == 0:
        break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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



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

Submission status: Accepted

Solution code:
N = int(input())

A = []
for i in range(100):
  if sum(A) >= 10e12:
    break
  A.append(pow(2,i))
if N == 1:
  print(1)
else:
  for i in range(50):
    N = N//2
    if N <= 0:
      print(sum(A[:i+1]))
      break

Submission status: Accepted

Solution code:
N = int(input())

count = 0

base = 1

# def calculator(hp):
#     if hp == 1:
#         return 1
#     else:
#         return (2 * calculator(hp // 2))
#
#
# print(calculator(N))

while N != 0:
    count += base
    N //= 2
    base *= 2

print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h=int(input())
num=0
now=0

while True:
    if h==1:
        break
    h=int(h/2)
    now+=2**num
    num+=1
    
print(now+2**num)

Submission status: Accepted

Solution code:
a=input()
A=int(a)
b=int(a)
c=0
d=1
for i in range(b):
    if A>1:
        A=int(A/2)
        c=c+int(d)
        d=d*2
    elif A==1:
        c=c+int(d)
        break
    else: break
print(c)

Submission status: Accepted

Solution code:
H = int(input())

index = 0
while(H!=1):
    H //= 2
    index += 1

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
import itertools
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))

def main():
	#N,K = inputMap()
	HH = inputInt()
	ans = 0

	H = []
	sin = []
	H.append(HH)

	cnte = 1
	flg = False
	while True:
		#print(cnte)
		if cnte % 2 == 1:
			sin = []
			for i,val in enumerate(H):
				if val <= 1:
					ans += 2**(cnte-1)
					continue
				else:
					flg = True
					ans += 2**(cnte-1)
					sin.append(val//2)
					#sin.append(val//2)
			if flg == False:
				print(ans)
				sys.exit()
			else:
				flg = False

		else:
			H = []
			for i,val in enumerate(sin):
				if val <= 1:
					#print("ss")
					ans += 2**(cnte-1)
					continue
				else:
					flg = True
					ans += 2**(cnte-1)
					H.append(val//2)
					#H.append(val//2)
			if flg == False:
				print(ans)
				sys.exit()
			else:
				flg = False

		cnte += 1

	#print(ans)




if __name__ == "__main__":
	main()

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
def Attack(i):
  goukei = 0
  if (i == 1):
    return 1
  else:
    goukei = goukei + 1
    goukei = goukei + Attack(int(i/2)) * 2
    return goukei

H = int(input())
goukei2 = Attack(H)

print(goukei2)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
H=int(input())

opt=[1]
while opt[-1]<=10**12:
    opt.append(opt[-1]*2+1)

count=0
temp=1
while temp<=H:
    temp*=2
    count+=1

print(opt[count-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    H = int(input())
    i = 2
    if H > 1:
        while True:
            if H <= 2 ** i - 1:
                break
            i += 1
        print(2 ** i - 1)
    else:
        print(1)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from math import log

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

Submission status: Accepted

Solution code:
nums = {1:1}
def num(k):
    if k in nums:
        return nums[k]
    else:
        nums[k] = 2 * num(k//2) + 1
        return nums[k]

h = int(input())
print(num(h))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import math

hp = int(input())

num = 0
sum = 0

while (math.ceil(hp) != 1):
    hp = int(hp / 2)
    num += 1

for kk in range(num+1):
    sum += 2**kk

print(sum)

Submission status: Accepted

Solution code:
H  = int(input())

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

Submission status: Accepted

Solution code:
import sys
 
if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
 
 
H=int(input())

cnt=0
p=0

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

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

Submission status: Accepted

Solution code:
H=int(input())
def check(h):
    if h==1:
        return(0)
    else:
        return(int(h/2))
count=0
multiply=1
while H>0:
    count+=multiply
    H=check(H)
    if H!=0:
        multiply*=2
print(count)

Submission status: Accepted

Solution code:
H = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h=int(input())
H=bin(h)
k=len(H)-2
A=2**k-1
print(A)

Submission status: Accepted

Solution code:
h = int(input().strip())

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

ans=(1-2**c)//(1-2)
print(ans)

Submission status: Accepted

Solution code:
h = int(input())
ans = 1
count = 0

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

print(ans)

Submission status: Accepted

Solution code:
h = int(input())
answer = 0
counter = 0
while True:
    if h == 1:
        break
    h = h // 2
    answer += pow(2, counter)
    counter += 1
print(answer + pow(2, counter))

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
import math
import time
import numpy as np
import collections
from collections import deque
import queue
import copy

# 最大公約数
def gcd(m,n):
  x = max(m,n)
  y = min(m,n)
  if x%y == 0:
    return y
  else:
    while x%y != 0:
      z = x%y
      x = y
      y = z
    else:
      return z

# 幅優先探索(BFS)でスタート座標(x, y)からの最大距離返す
def bfs(SS, x, y, H, W):#入力(座標系(迷路), x, y, xの端, yの端)
  x_next = [0, 0, -1, 1]
  y_next = [1, -1, 0, 0]
  tempx = x
  tempy = y
  mlength = 0
  q = deque()
  xytuple = (x, y, 0)
  q.append(xytuple)


  while q:
    xytuple = q.popleft()
    SS[xytuple[0]][xytuple[1]] = "x" #探索した場所は探索できないようにする
    for i in range(4): #このforで上下左右を調べてる
      tempx = xytuple[0] + x_next[i]
      tempy = xytuple[1] + y_next[i]
      #print(tempx, tempy, xytuple[2])
      #print(S)
      if(0 <= tempx and tempx < H and 0 <= tempy and tempy < W and SS[tempx][tempy] == "."):
        temptuple = (tempx, tempy, xytuple[2]+1)
        SS[temptuple[0]][temptuple[1]] = "x" #探索した場所は探索できないようにする
        mlength = max(mlength, xytuple[2] +1)
        q.append(temptuple)
      #print(q)
  return mlength

def brick(a,n,m,N):#ABC 148
  #n番目以降にmがあるか調べる
  if not m in a[n:]:
    print(N-(m-1))
  else:
    #b = copy.deepcopy(a)
    brick(a,a[n:].index(m),m+1,N)

#X = str(input()).split()
#a = [int(x) for x in input().split()]
#HA = str(input()).split()
H = int(input())
#A = int(HA[1])
#a = [int(x) for x in input().split()]

H_str = bin(H)

bit = len(H_str)-3

ans = 2 ** bit
ans = ans *2
ans -= 1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 整数を一つ入力
h = int(input())

n = 0
a = 0
while 1:
    a = a + 2 ** n
    if h == 1:
        break
    h = h // 2
    n = n + 1

print(a)

Submission status: Accepted

Solution code:
H=int(input())
N=0
ans=0

while(H>=1):
	H=H//2
	N+=1
	#print(H,N)

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

print(ans)

Submission status: Accepted

Solution code:
H = int(input())

count = 0

while(H!=0):
    if H==1:
        H=0
        count+=1
    else:
        H=int(H/2)
        count+=1

ans = 0

for i in range(count):
    ans += pow(2, i)

print(ans)

Submission status: Accepted

Solution code:
H = int(input())

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

print(2**i-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
NB=format(N,'0b')
K=len(NB)
print(2**K-1)

Submission status: Accepted

Solution code:
from math import log2, floor

h = int(input())
t = floor(log2(h))

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

Submission status: Accepted

Solution code:
h = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
h = int(input())
count = 0
while True:
  count+=1
  half = h/2
  h = math.floor(half)
  if half < 1:
    break  
    
ans = 0
plus = 1
for i in range(count):
  ans += plus
  plus *= 2

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H = int(read())

answer = 0
coef = 1
while H:
    answer += coef
    H //= 2
    coef *= 2

print(answer)

Submission status: Accepted

Solution code:
h = int(input())

ans = 1
bit = 1

while True:
    if h == 1:
        break
    h = int(h / 2)
    bit = bit << 1
    ans += bit

print(ans)

Submission status: Accepted

Solution code:
import math
h = int(input())
if h == 1:
    print(1)
    exit()

x = 0
c = 1
while h >= 1:
    h = math.floor(h/2)
    x += c
    c *= 2

print(x)

Submission status: Accepted

Solution code:
import math

health = int(input())
depth = int(math.log2(health))
print(sum([2 ** d for d in range(depth + 1)]))

Submission status: Accepted

Solution code:
import math

H = int(input())

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

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

Submission status: Accepted

Solution code:
h = int(input())

count = 0
for i in range(h):
    count += 2**i
    h = h//2
    if h == 0:
        break
print(count)

Submission status: Accepted

Solution code:
#coding: utf-8

import math

H = int(input())
nth=0
ret = 0

while(H>0):
    H = math.floor(H/2)
    ret += math.pow(2, nth)
    nth += 1

print(int(ret))

Submission status: Accepted

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


n = int(input())
print(count_attack(n))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())
m = 0
while h > 1:
  h = h//2
  m += 1
out = 0  
for i in range(m+1):
  out += 2**i
print(out)

Submission status: Accepted

Solution code:
H = int(input())

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

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

Submission status: Accepted

Solution code:
H = int(input())
a = H
b = 0
while a>1:
    b+=1
    a = a //2
ans = sum([2**x for x in range(b+1)])
print(ans)

Submission status: Accepted

Solution code:
import numpy as np
import math
H = int(input())

cnt = np.log2(H)
cnt = math.floor(cnt)
cnt = 2**(cnt + 1) - 1
print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8


H = int(input())

# ans = 0


def rec(x):
    # global ans
    if x > 1:
        return 1 + 2 * rec(x//2)
    else:
        return 1


print(rec(H))

Submission status: Accepted

Solution code:
h = int(input())

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

ans += (2 ** i)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())
f = [0] * 100
f[0] = 1
for i in range(1, 100):
  f[i] = 1 + f[i-1] * 2
  
num = 1
while h >= 2 ** (num):
  num += 1
  
ans = f[num - 1]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())
s = len(str(bin(h))) - 3
ans = [1]
for i in range(1,45):
    ans.append(ans[-1] * 2 + 1)

print(ans[s])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(raw_input())

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

print count

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
binLength = len(str(bin(a))) - 2
print((2 ** binLength) - 1)

Submission status: Accepted

Solution code:
H = int(input())
bin_str = format(H,"b")
t = len(bin_str)
jud = 0
a = 1
result = 0
for i in range(t):
    if bin_str[i] != "0":
        jud = 1 
        break
        
if jud == 0:
    for i in range(t+1):
        result += a
        a *= 2
else:
    for i in range(t):
        result += a
        a *= 2
print(result)

Submission status: Accepted

Solution code:
h=int(input())
if h==1:
    print(1)
else:
    num=1
    while 2**num<=h:
        num+=1
    #print(num) #グループのチェック
    ans=1
    num2=1
    for i in range(num-1):
        ans+=(2**num2)
        num2+=1
    print(ans)

Submission status: Accepted

Solution code:
#D
#入力
H=int(input())
def D(n):
    if n==1:
        return 1
    else:
        return 2*D(n//2)+1
print(D(H))

Submission status: Accepted

Solution code:
def main():

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

    return ans

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

Submission status: Accepted

Solution code:
H=int(input())
if H==1:
    print(1)
else:
    n=1
    ans=1
    while H!=1:
        H=H//2
        n*=2
        ans+=n
    print(ans)

Submission status: Accepted

Solution code:
import math
h = int(input())
target = math.floor(math.log2(h)) + 1
print(2**target - 1)

Submission status: Accepted

Solution code:
import math

H = int(input())

n = math.log2(H)
n = int(n)
res = 1


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

Submission status: Accepted

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

h = ii()
dp = [0] * 50
dp[0] = 1
for i in range(1,50):
    dp[i] = 2 * dp[i-1] + 1
ima = 0
while True:
    if 2 ** ima <= h:
        ima +=1
    else:
        break
if (2 ** ima) == h:
    print(dp[ima])
else:
    print(dp[ima-1])

Submission status: Accepted

Solution code:
H = int(input())

count = 0
split = 0

mons_HP = H

while mons_HP != 0:
    if mons_HP == 1:
        mons_HP = 0
        count += 2**(split)
    else :
        crnt_HP = mons_HP
        mons_HP = int(crnt_HP/2)
        count += 2**(split)
        split += 1

print(count)

Submission status: Accepted

Solution code:
h = int(input())

i = 0
while(2**i <= h):
  i += 1
i -= 1

c = 0
while(i >= 0):
  c += 2**i
  i -= 1
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H=int(input())

import math

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

    
print(count(H))

Submission status: Accepted

Solution code:
h = int(input())

for i in range(41):
    tmp = 2**i
    if h < tmp:
        print(tmp - 1)
        exit()

Submission status: Accepted

Solution code:
from sys import stdin
h = int(stdin.readline().rstrip())

waru = True
warucount = 0
while waru:
    if h == 1:
        break
    h = h // 2
    warucount += 1
ones = 2 ** warucount

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

Submission status: Accepted

Solution code:

import math
H=int(input())
count=0
bunretsunum=0
while True:
    if H>1:
        H=int(math.floor(H/2))
        count=count+int(math.pow(2,bunretsunum))
        bunretsunum=bunretsunum+1
    else:
        count=count+int(math.pow(2,bunretsunum))
        break
print(count)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H=int(input())

count=0
answer=1

while H>1:
    count+=1
    answer+=2**count    
    H//=2

print(answer)