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:
h = int(input())
a = 0
kaisuu = 0
for i in range(50):
    if 2**(i)<=h and h <2**(i+1):
        a = i
        kaisuu += 2**i
        break
    else:
        kaisuu += 2**i
print(kaisuu)

Submission status: Accepted

Solution code:
hp_init = int(input())
hp = hp_init
num = 1
ans = 0

while hp > 0:
    ans += num
    hp //= 2
    num *= 2

print(ans)

Submission status: Accepted

Solution code:
def f(h):
    return 0 if h==0 else 1 + 2*f(int(h/2))

h = int(input())
print(f(h))

Submission status: Accepted

Solution code:
import math

h = int(input())

ans = 0
add_v = 1

while True:
    if h < 1:
        break
    h = math.floor(h / 2)
    ans += add_v
    add_v *= 2
print(ans)

Submission status: Accepted

Solution code:
import math
def py():
    print("yes")
def pn():
    print("no")
def iin():
    x = int(input())
    return x

neko = 1
nya = 1
nuko = 0

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
H = int(input())
a = int(math.log2(H))
print((pow(2, a+1)-1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

def main():
    n = int(input())
    i = 0
    while n > 0:
        i += 1
        n //= 2

    print(2**i - 1)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())

ans = H
cnt = 1

def attack(h, ans, cnt):
    if h==1:
        return(ans)
    else:
        if h%2==0:
            ans += (1*cnt)
        h = h//2
        cnt *= 2
        return attack(h, ans, cnt)

ans = attack(H, ans, cnt)

print(ans)

Submission status: Accepted

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

H = int(input())
def attack_count(X):
    if X == 1:
        return 1
    return 1+2*attack_count(X//2)

print(attack_count(H))

Submission status: Accepted

Solution code:
import math
H=int(input())
a=H
ans=1
while a>1:
  a=math.floor(a/2)
  ans+=1
Ans=2**(ans)
print(Ans-1)

Submission status: Accepted

Solution code:
H = int(input())

n = 0
A = 0
while H:
    if H == 1:
        A += 2**n
        break
    H //= 2
    A += 2**n
    #print(A, n, 2**n)
    n += 1
    
    
#print(n)
print(A)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H=int(input())

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

Submission status: Accepted

Solution code:
import fractions
power = int(fractions.math.log2(int(input())))
ans = 0
for p in range(power+1):
  ans += 2**p
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    from functools import lru_cache
    n = int(input())

    @lru_cache(maxsize=1000)
    def attack(i):
        if i == 1:
            return 1
        else:
            return 1 + attack(i // 2) + attack(i // 2)

    print(attack(n))


resolve()

Submission status: Accepted

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

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

print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

h = int(input())
n = math.floor(math.log(h , 2))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())

num = 0
plusvalue = 1
while True:
    if h % 2 == 1:
        h -= 1
    h //= 2
    num += plusvalue
    plusvalue *= 2
    if h == 0:
        break
print(num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h=int(input())

for i in range(50):
    if 2**i <= h and h < 2**(i+1):
        print(2**(i+1)-1)

Submission status: Accepted

Solution code:
H = int(input())

a = [1]
for i in range(1, 41):
    a.append(a[i-1]*2 + 1)
#print(a)

for k in range(41):
    if 2**k <= H and H < 2**(k+1):
        print(a[k])
        break

Submission status: Accepted

Solution code:
H = int(input())

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


result = calculate(H)

print(result)

Submission status: Accepted

Solution code:
import math

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

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

Submission status: Accepted

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

Submission status: Accepted

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

print(count)

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

cnt = 1
res = 1
while n != 1:
    n = n // 2
    cnt = cnt*2
    res += cnt
print(res)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
import math

h = int(input())

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Fri May  8 15:34:23 2020

@author: shinba
"""

h = int(input())

cnt = 1

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

print(2**cnt-1)

Submission status: Accepted

Solution code:
def aaa():
    a=int(input())
    count=0
    at=1
    while a>0:
        a//=2
        count+=at
        at*=2
    print(count)

if __name__=='__main__':
    aaa()

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


def main():
    h = int(stdin.readline())

    ans = 0

    while 2 ** (ans + 1) <= h:
        ans += 1

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


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

Solution code:
h = int(input())

ans = 1
while True:
  if h<ans:
    break
  ans*=2
print(ans-1)

Submission status: Accepted

Solution code:
def main():
    h=int(input())
    ans=0
    tmp=1
    while h>0:
        h//=2
        ans+=tmp
        tmp*=2
    print(ans)
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

h = int(input())

print(half(h))

Submission status: Accepted

Solution code:
import math
H = int(input())
n = int(math.log(H,2))
print(pow(2,n+1)-1)

Submission status: Accepted

Solution code:
h = int(input())

num = 0
n = 0

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

Submission status: Accepted

Solution code:
h = int(input())

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

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

Submission status: Accepted

Solution code:
import sys
from io import StringIO
import unittest


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

def resolve():
    h = int(input())
    print(calc(h))


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)


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

h = H
enemies = 0
counter = 0

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

print(2**counter - 1)

Submission status: Accepted

Solution code:
x = int(input())

Sum = 1
tmpn = 1
while x != 1:
  tmpn *= 2
  Sum += tmpn
  x = int(x/2)

print(Sum)

Submission status: Accepted

Solution code:
# D - Caracal vs Monster

H = int(input())

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

print(attack_cnt(H))

Submission status: Accepted

Solution code:
# D - Caracal vs Monster

H = int(input())

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

print(cnt)

Submission status: Accepted

Solution code:
import math
h = int(input())
temp = 1
ans = 0


def calc(x):
    a = math.floor(x / 2)
    return a


if (h == 1):
    print('1')
else:
    while (h >= 1):
        h = calc(h)
        ans += temp
        temp *= 2
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())

def func(x):
    if x == 1:
        return 1
    else:
        a = func(x//2)
        return a*2+1

print(func(h))

Submission status: Accepted

Solution code:
h = int(input())

ans = 0
x = 0

def dfs(h,x):
    global ans
    if h == 1:
        ans += 2**x
        return
    else:
        ans += 2**x
        h //= 2
        x += 1
        dfs(h, x)
        
dfs(h,x)

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
import sys
def I(): return int(input())  # '123' -> 123
def Is(): return map(int, input().split())  # '123 456' -> 123, 456
def LI(): return list(map(int, input().split()))  # '123 456' -> [123, 456]
def TI(): return tuple(map(int, input().split()))  # '123 456' -> (123, 456)
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()  # 'aa bb' -> 'aa','bb' or ['aa','bb']
def LS(): return list(input())  # 'abc123' -> ['a','b','c','1','2','3']
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(1000000)
MOD = 1000000007
INF = float('inf')

h = I()
mul = 1
ans = 0
while h > 0:
    h = floor(h/2)
    ans += mul
    mul *= 2

print(ans)

Submission status: Accepted

Solution code:
HP = int(input())
if HP == 1:
  print("1")

else:
  #print(bin(HP))
  print(pow(2,len(bin(HP))-2)-1)

Submission status: Accepted

Solution code:
h = int(input())

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

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

Submission status: Accepted

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

print(a(h))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())

for i in range(40):
  if 2 ** i <= H < 2 ** (i + 1):
    print((2 ** (i + 1) - 1)) 
    exit()

Submission status: Accepted

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

A = 0
for a in range(count):
    A += 2 ** a

result = 2 ** count + A
print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

h = int(input())

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

print(f(h))

Submission status: Accepted

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

if h ==1:
 print(1)
else:
 while True:
  h=h//2
  a+=1
  if h//2==0:
   break

 print(2**a-1)

Submission status: Accepted

Solution code:
import sys
h = int(input())
i = 0
j = 0
while h !=1:
    h = int(h/2)
    j += 2**i
    i += 1
print(j+2**i)

Submission status: Accepted

Solution code:
h = int(input())

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

Submission status: Accepted

Solution code:
H=int(input())

def time(h):
  if h==1:
    return 1
  else:
    return time(h//2)*2 + 1
print(time(H))

Submission status: Accepted

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

while H>=2**i:
  if H<2**(i+1):
    break
  else:
    i+=1
  
for j in range(i+1):
  c+=2**j

  
print(c)

Submission status: Accepted

Solution code:
H=int(input())

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

Submission status: Accepted

Solution code:
import math

H = int(input())

i = 1
count = 0
monster = [H, 1]
while i > 0:
  count += monster[1]
  new_monster = math.floor(monster[0] / 2)
  monster = [new_monster, monster[1] * 2]
  if new_monster == 0:
    print(count)
    break

Submission status: Accepted

Solution code:

h = int(input())
for i in range(0, 48):
    if 2**i <= h <= 2**(i+1) - 1:
        print(2**(i+1) - 1)

Submission status: Accepted

Solution code:
def attack_num(x):
    if x == 1:
        return 1
    else:
        return 1 + 2 * attack_num(x//2)


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

H = int(input())

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

print(2**c - 1)

Submission status: Accepted

Solution code:
H = int(input())

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import count


def main():
    H = int(input())
    for i in count():
        if 2 ** i > H:
            print(2**i-1)
            exit()


def test():
    for H in range(1, 101):
        monster = [H]
        ans = 0
        while len(monster) > 0:
            tmp = list()
            for m in monster:
                if m != 1:
                    tmp.extend([m//2]*2)
                ans += 1
            monster = tmp
        print(ans)


def test2():
    H = 10 ** 12
    ans = 0
    while H > 1:
        H //= 2
        ans += 1
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
H = int(input())

ans = 0
count = 0
while True:
    ans += 2**count
    if H == 1:
        break
    else:
        H //= 2
        count += 1

print(ans)

Submission status: Accepted

Solution code:
def fanc(x):
    if x == 1:
        return 1
    else:
        return 2*fanc(x//2)+1


h = int(input())
print(fanc(h))

Submission status: Accepted

Solution code:
def defeat(x):
  if x == 1:
    return 1
  else:
    return 1 + 2 * defeat(x // 2)

H = int(input())
print(defeat(H))

Submission status: Accepted

Solution code:
import math

H = int(input())

k = int(math.log2(H))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
h = int(input())
rest = [h]
c = 0
for i in range(10**100):
    if rest[i]==1:
        c += 2**i
        break
    
    rest.append(int(rest[i]/2))
    c += 2**i

print(c)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math

def solve(H: int):
    n = int(math.log(H, 2))
    
    a = 1
    sum = 0
    for _ in range(0, n + 1):
        sum += a
        a *= 2
    
    print(sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    solve(H)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(x-1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
H=int(input())
a=1
count=1

while True:
  if H!=1:
    H=math.floor(H/2)
    a=a*2
    count += a  
   
  else:
    break
    
print(count)

Submission status: Accepted

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

Submission status: Accepted

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

print(attack(n = int(input())))

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    h=int(input())
    cnt=1
    while h>1:
        h=h//2
        cnt+=1
    print((1-2**cnt)//(1-2))
resolve()

Submission status: Accepted

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

while h != 0:
    h //= 2
    att += 1
    
print(2**att - 1)

Submission status: Accepted

Solution code:
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:
INT_MAX=10**11+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#=======================================================================
n=int(input())
ans=0
x=1
while(n!=0):
    ans+=x
    x*=2
    n//=2
print(ans)

Submission status: Accepted

Solution code:
H = int(input())
count = 0
while H > 0:
    H = H // 2
    count += 1
res = 0
a = 1
for i in range(1, count + 1):
    res += a
    a *= 2
print(res)

Submission status: Accepted

Solution code:
H = int(input())

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

Submission status: Accepted

Solution code:
def solve(n):
    if n in memo: return memo[n]
    memo[n] = 2*solve(n//2)+1

    return memo[n]

memo = {1:1}

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

Submission status: Accepted

Solution code:
H=int(input())

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

print(str(kaisuu(H)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

h = int(input())
log = math.floor(math.log(h,2))
print(pow(2,log+1)-1)

Submission status: Accepted

Solution code:
h=int(input())
(ans,cnt,cnt2)=(0,0,0)
while h>1:
	h=h//2
	ans=ans+(1<<cnt)
	cnt=cnt+1
	cnt2=cnt2+1
ans=ans+(1<<cnt2)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def cnt(hp):
    if hp == 1:
        return 1
    else:
        return 2 * cnt(hp//2) + 1

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
H = int(input())
I = len(bin(H))-3
Sn = 2**(I+1)-1
print(Sn)

Submission status: Accepted

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

abc153_d()

Submission status: Accepted

Solution code:
from math import floor

def recursive(H):
   # print(H)
   if(H == 1):
      return 1
   else:
      return recursive(floor(H/2))*2 + 1

def myAnswer(H:int) ->int:
   return (recursive(H))



def modelAnswer():
   tmp=1
def main():
   H = int(input())
   print(myAnswer(H))

if __name__ == '__main__':
   main()

Submission status: Accepted

Solution code:
H = int(input())

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

Submission status: Accepted

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

h=int(input())

if h==1:
    print(1)
else:
    cnt=1
    while cnt<=h:
        cnt*=2
    print(cnt-1)

Submission status: Accepted

Solution code:
H = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())

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

Submission status: Accepted

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

sum=0
for j in range(count):
  sum+=2**j

print(sum)

Submission status: Accepted

Solution code:
from __future__ import print_function

from functools import reduce
from operator import mul
from collections import Counter
from collections import deque
from itertools import accumulate
from queue import Queue
from queue import PriorityQueue as pq
from heapq import heapreplace
from heapq import heapify
from heapq import heappushpop
from heapq import heappop
from heapq import heappush
import heapq
import time
import random
import bisect
import itertools
import collections
from fractions import Fraction
import fractions
import string
import math
import operator
import functools
import copy
import array
import re
import sys
sys.setrecursionlimit(500000)


input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    #
    def rec(n, j):  # 「nを0にするのに必要な「2での割り算」の回数」を返す再帰関数
        if n == 0:
            return j
        else:
            return rec(n//2, j+1)

    # input
    h = int(input().strip())

    # procedure
    cnt = 0
    for i in range(rec(h, 0)):
        cnt += 2**i

    # output
    print(cnt)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys
sys.setrecursionlimit(500000)

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return

# from fractions import gcd
# from math import gcd

# def lcm(n, m):
#     return int(n * m / gcd(n, m))


# def coprimize(p, q):
#     common = gcd(p, q)
#     return (p // common, q // common)


# def find_gcd(list_l):
#     x = reduce(gcd, list_l)
#     return x


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def main():
    n = int(input().strip())

    def rec(m,j):
        if m==0:
            return 0
        else:
            return 2**j + rec(m//2,j+1)
            
        
    print(rec(n,0))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
H = int(input())

# 2倍になる回数
cnt = 0

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

# 攻撃回数
ans = 1
for i in range(cnt):
    ans = 1 + ans * 2

print(ans)

Submission status: Accepted

Solution code:
h = int(input())
b = bin(h)
l = len(b)-2
print(2**l-1)

Submission status: Accepted

Solution code:
h = int(input())

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

Submission status: Accepted

Solution code:
H=int(input())
ans=0
now=H
kazu=1
while(True):
  if 1<now:
    ans+=kazu
    now=now//2
    kazu=kazu*2
  else:
    ans+=kazu
    break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
H = int(input())
step = 1
count = 1
while 1 < H:
  H //= 2
  step *= 2
  count += step
print(count)

Submission status: Accepted

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

def nested(v,depth):
    while v!=1:
        depth+=1
        v=math.floor(v/2)

    return depth+1

print(sum([2**i for i in range(nested(H,0)) ]))

Submission status: Accepted

Solution code:
import math
import sys

h = int(sys.stdin.readline().rstrip())
ans = 0
tmp = 0
while (1):
    if 2 ** tmp > h:
        break
    ans += 2 ** tmp
    tmp += 1
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 9)
if __name__ == '__main__':
    def solve(x):
        if x == 1:
            return 1
        else:
            return 2 * solve(x // 2) + 1
    h = int(input())
    print(solve(h))

Submission status: Accepted

Solution code:
H = int(input())

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
import math

def solve(H: int):
    n = int(math.log2(H))
    print(pow(2, n+1)-1)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    H = int(next(tokens))  # type: int
    solve(H)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
h = int(input())
ans = -1

for i in range(100000000):
    if h+0.5<2**i:
        ans += 2**i
        break

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
H = int(input())
atkcnt = 0
n = 0
while 1:
    if H > 0:
        H //= 2
        atkcnt += 2 ** n
    else:
        break
    n += 1
print(atkcnt)