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: Wrong Answer

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

def solve(H: int):

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

    i = 1
    m = 1

    flag = True
    while True:
        if H == 8:
            flag = False
        H = -(-H // 2)
        i *= 2
        if H == 1:
            if flag:
                i += i
            i -=1
            break
    print(i)

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: Wrong Answer

Solution code:
h = int(input())

double = 0
for i in range(h, 1, -1):
  if h == 1:
    break
  h = h // 2
  double += 1

print(double + 1)
total = 0
for i in range(double + 1):
  total += pow(2, i)
print(total)

Submission status: Wrong Answer

Solution code:
h = int(input())

sum=0

for i in range(int(h/2)+1):
    sum = sum+(2**i)
print(sum)

Submission status: Wrong Answer

Solution code:
import math

h=int(input())
if h==1:
  print(1)
  exit(0)
tmp=math.log(h, 2)
tmp2=math.floor(tmp)
if tmp-tmp2>0:
  h=h//2+1
count=0
for i in range(h):
  p=int(math.pow(2, i))
  if h<p:break
  count+=h//p
print(count)

Submission status: Wrong Answer

Solution code:
H = int(input())
key = H
i = 0
mon_cnt = [1]
while key > 1:
    key = round(key / 2)
    key_box = []
    i += 1
    for _ in range(2 ** i):
        mon_cnt.append(key)
print(len(mon_cnt))

Submission status: Wrong Answer

Solution code:
H = int(input())
i = 1
while H > 1:
    H = -(-H//2)
    print("H=%d,i=%d" % (H,i))
    if H >= 1:
        i += 1
print(2**i-1)

Submission status: Wrong Answer

Solution code:
import math

H = int(input())

count = 1
while True:
    if H == 1:
        break
    H = math.ceil(H/2)
    count += 1

print(2**count-1)

Submission status: Wrong Answer

Solution code:
h = int(input())

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
h = input()
h = int(h)
count = 0
attack = 0

if h > 1:
  while h > 1:
    h = h / 2 
    count = count + 1
  for i in range(0, count):
    attack = attack + (2**i)
  print(attack)
else:
  print(1)

Submission status: Wrong Answer

Solution code:
h = int(input())

res = 0
i = 1

while h > 0:
  h = h//2
  res = res + i
  i*2
print(res)

Submission status: Wrong Answer

Solution code:
import math
monsters = [int(input())]
attack_count = 0
while sum(monsters) > 0:
	attack_count += 1
	if monsters[0] == 1:
		del monsters[0]
	else:
		new_h = math.ceil(monsters[0]/2)
		del monsters[0]
		new_monsters = [new_h, new_h]
		monsters.extend(new_monsters)
print(attack_count)

Submission status: Wrong Answer

Solution code:
d = int(input())

kaisu = 0

def atack(tairyoku):
    global kaisu

    if tairyoku <=1:
        return

    kaisu += 1
    atack(tairyoku/2)

atack(d)


ans = 0
def keisan(x):
    global ans
    if x == 0:
        return
    ans += x
    keisan(int(x/2))


keisan(2**kaisu)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input()) 
for i in range(0,1000000) : 
    H = n/(2**i)
    if H <= 1 : 
        a = i 
        break 
sum = 0
for i in range(0,a+1) : 
    sum = sum + (2**i) 
print(sum)

Submission status: Wrong Answer

Solution code:
import math
H = int(input())
monster_num = 1
attack = 0
while H > 1:
    attack = attack + monster_num * 1
    H = math.ceil(H/2)
    monster_num = monster_num * 2

print(monster_num + attack)

Submission status: Wrong Answer

Solution code:
n = int(input())


if n % 2 == 1:
    n -= 1

def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x


print(2*pow_k(2,int(n/2))-1)

Submission status: Wrong Answer

Solution code:
import math

N = int(input())
didnot = False
def waru2(n, didnot):
  c = 0
  while True:
    if n == 1:
      break
    n = int(math.ceil(n/2))
    if n != 1 and n % 2 != 0:
      didnot = True
    c += 1
  return (c, didnot)

a, didnot = waru2(N, didnot)
c = 0
for i in range(a):
  c += 2**i

if didnot:
  print(c)
else:
  print(c+N)

Submission status: Wrong Answer

Solution code:
N=int(input())

def sep_to_1(n):
    sep_mon=n
    count=0
    mons_num=1
    sum_sep_count=0
    while sep_mon!=1:
        count+=1
#         print("stage",count)
        sep_mon=sep_mon//2
        sum_sep_count+=mons_num
        mons_num=2*mons_num
        
#         print("sep_mon",sep_mon)
#         print("mons_num",mons_num)
#         print("sum_sep_count",sum_sep_count)
    return sum_sep_count

print(sep_to_1(N)+N)

Submission status: Wrong Answer

Solution code:
h = int(input())
m = 0 # モンスター数
a = 0 # 分裂回数
i = 0 # ループ回数
while True:
    i += 1
    # 攻撃して分裂した
    if h > 1:
        h = int(h/2)
        m += 2
        a += i
        continue
    # 1のモンスターを消滅させるまでの回数
    else:
        print(a+m)
        break

Submission status: Wrong Answer

Solution code:
n = input()
n = int(n)
count = 0
attack = 0

if n > 1:
  while n > 1:
    n = n / 2 
    count = count + 1
  for i in range(0, count):
    attack = attack + (2**i)
  print(attack)
else:
  print("1")

Submission status: Wrong Answer

Solution code:
import math
import numpy as np
H=int(input())
if H==1:
    print(1)
elif H==3:
    print(3)
else:
    n = int(np.log2(H+1))
    ans = 2**(n+1)-1
    print(ans)

Submission status: Wrong Answer

Solution code:
import math
import numpy as np
H=int(input())
if H==1:
    print(1)
else:
    n = int(np.log2(H+1))
    ans = 2**(n+1)-1
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
flag = True
ans = 1
now = n
count = 1
while flag == True:
    if now == 1:
        ans += count
        print(ans)
        break
    now = now/2
    if count != 1:
        ans += count
        # print(ans)
        count = count*2
        # print(count)
    else:
        # print(ans)
        count = 1*2

Submission status: Wrong Answer

Solution code:
H = int(input())


branch = 1

leafs = []

while True:
	if H <= 1:
		break
	H = H / 2

	leafs.append(2**(branch))

	branch += 1



print(sum(leafs)+1)

Submission status: Wrong Answer

Solution code:
n = int(input())
flag = True
ans = 1
now = n
count = 1
while flag == True:
    if now == 1:
        ans += count
        print(ans)
        break
    now = now/2
    if count != 1:
        ans += count
        print("now",now)
        # print(ans)
        count = count*2
        # print(count)
    else:
        print("now",now)
        # print(ans)
        count = 1*2

Submission status: Wrong Answer

Solution code:
import math

h=int(input())

i=1

while not(h==1):
  h=math.ceil(h/2)
  i+=1

r=2 ** i
r=r-1
print(r)

Submission status: Wrong Answer

Solution code:
h = int(input())
mem = [0] * 1000
cnt = 0

def atk(k):
    if k == 1:
        return 1
    else:
        j = int(k // 2)
        l = 0
        while k / ( 2 ** l) >1:
            l += 1

        if mem[l] == 0:
            mem[l] = atk(j) * 2 + 1
            return mem[l]
        else:        
            return mem[l]
mem[1] = 1
atk(h)
mem.sort(reverse = True)
print(mem[0])

Submission status: Wrong Answer

Solution code:
count = 1

def number(h,count):
    if h<= 1:
        return count
    else:
        return number(h//2,count+1)
h = int(input())
#print(keisan(h,count))
key = number(h//2,count)
ans = 0
for i in range(1,key+1):
    ans += 2**i
print(ans+1)

Submission status: Wrong Answer

Solution code:
H = int(input())

i = 0
j = 1
if H == 1:
  print(1)
else:
  while H != 1:
    H = H//2
    i += 2**j
    j += 1

print(i + 1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
h = int(input())
mem = [0] * 1000

def atk(k):
    if k == 1:
        return 1
    else:
        j = int(k // 2)
        l = 0
        while k / ( 2 ** l) >1:
            l += 1

        if mem[l] == 0:
            mem[l] = atk(j) * 2 + 1
            return mem[l]
        else:        
            return mem[l]
atk(h)
mem.sort(reverse = True)
print(mem[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
LogT={1:1}
def  div2(X):
    if X in LogT:
        return LogT[X]
    else:
        v = 1+div2(math.floor(X/2))*2
        LogT[X]=v
        return v

if __name__=='__main__':
    H=int(input())

Submission status: Wrong Answer

Solution code:
H = int(input())

cnt = 0
ans = 0

if H % 4 == 0:
    print((H - 1) * 2 + 1)
    exit()

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

print(ans)

Submission status: Wrong Answer

Solution code:
def split_monster(n, count):
  if n == 0:
    return count
  count += 1
  count = split_monster(int(n/2), count)
  count = split_monster(int(n/2), count)
  return count
 
n = int(input())
count = 0
if n > 1:
	count = split_monster(n, count)
  
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
H=int(input())
if H==1:
    print(1)
else:
    n = int(math.log2(H+1))
    ans = 2**(n+1)-1
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
H=int(input())
ans = 0
print(H)
while H > 1:
    if H%2 == 0:
        H = H/2
        ans += 1
    else:
        H = (H-1)/2
        ans += 1
N = 2**ans
def fight(k):
    if k == 1:
        return 1
    else:
        return 2*fight(k/2)+1
    
        
print(fight(N))

Submission status: Wrong Answer

Solution code:
import math

H = int(input())

def hitpoint(hits, ans):
    result = []

    for i in hits:
        ans += 1
        if i == 1:
            continue

        remain = math.ceil(i / 2)
        if remain > 0:
            result.append(remain)
            result.append(remain)

    return result, ans

hits = [H]
ans = 0
while(True):
    hits, ans = hitpoint(hits, ans)
    if len(hits) == 0:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [1]

if n % 2 == 1:
    n -= 1

if n % 2 == 0:
    for i in range(int(n/2)):
        a.append(2*a[i])

print(sum(a))

Submission status: Wrong Answer

Solution code:
import math

h=int(input())

if(100<h):
  i=0
else:
  i=1


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

else:
  while(1<h):
    h=math.ceil(h/2)
    i+=1

r=2 ** i
r=r-1
print(r)

Submission status: Wrong Answer

Solution code:
import math

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

if H <= 8:
  if H==1:
    print(1)
  else:
  	print(2**(n+1)-1)
else:
  print(2**(n+1)-1)

Submission status: Wrong Answer

Solution code:

h = int(input())

fighting_monster_hp = h
fighting_monster_number = 1
total_attack = 0

while 1 < fighting_monster_hp:
    # 今の敵を倒す
    total_attack = total_attack + fighting_monster_number
    # 次の敵が出現
    fighting_monster_hp = fighting_monster_hp * 0.5
    fighting_monster_number = fighting_monster_number * 2

# 敵のHPが1になったので、今いる敵でおしまい
total_attack = total_attack + fighting_monster_number

print(total_attack)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

if H <= 1024:
  if H==1:
    print(1)
  else:
  	print(2**(n)-1)
else:
  print(2**(n)-1)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

if H <= 16:
  if H==1:
    print(1)
  else:
  	print(2**(n+1)-1)
else:
  print(2**(n)-1)

Submission status: Wrong Answer

Solution code:
h = int(input())
for i in range(1, 41):
  x = 2 ** i -1
  if h <= x:
    print(x)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

import math
h = int(input())
i = 0
c = 0
while h != 0:
    c += 2**i
    if h > 1:
        h = math.ceil(h/2)
    else:
        h = 0
    i += 1
print(c)

Submission status: Wrong Answer

Solution code:
import math

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

if H < 8:
  if H==1:
    print(1)
  else:
  	print(2**(n+1)-1)
else:
  print(2**(n)-1)

Submission status: Wrong Answer

Solution code:
import math
h = int(input())
a = 0
while 2**a < h:
    a+=1
c = -1+2**(a+1)
if c <= 10**12:
    print(-1+2**(a+1))
else:
    print(2**40-1)

Submission status: Wrong Answer

Solution code:
import math

h=int(input())
i=1

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

else:
  while(1<h):
    h=math.ceil(h/2)
    i+=1
    print("h="+str(h))
    print("i="+str(i))

r=2 ** i
r=r-1
print(r)

Submission status: Wrong Answer

Solution code:
H = int(input())

ans = 0
n = 1

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


if H == 1:
    print(1)
else:
    ans = calc(H,n)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
h = int(input())

import math

if h == 1:
    print(1)

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

    gsum = 1

    for x in range(n_attacks + 1):
        gsum += 2 ** (x + 1)
        
    print(gsum)

Submission status: Wrong Answer

Solution code:
import math

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

if H < 8:
  print(2**(n+1)-1)
else:
  print(2**(n)-1)

Submission status: Wrong Answer

Solution code:
import math

monster_hp_list = []
monster_hp_list.append(int(input()))

count = 0

while(len(monster_hp_list)>0):
    
    if monster_hp_list[0] == 1:
        monster_hp_list.pop(0)
        count += 1
    elif monster_hp_list[0] > 1:
        harved_hp = math.floor(monster_hp_list[0]/2)
        monster_hp_list.pop(0)
        for twice in range(2):
            monster_hp_list.append(harved_hp)
            
        count += 1

Submission status: Wrong Answer

Solution code:
h = int(input())
cnt = 0
if h == 2:
    print(3)

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

Submission status: Wrong Answer

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

while True:

    H //= 2
    i += 1
    result += 2**i
    if H == 1:
        break

print(result)

Submission status: Wrong Answer

Solution code:
h=int(input())
h1=h
icnt=1
for i in range(1000):
    h1=h1//2
    icnt=icnt+1
    if h1<=1:
        break
    
s=int(2**icnt)-1
print(s)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
H = int(input())
if H==1:
  print(1)
elif 2 <= H and H <= 3:
  print(3)
elif 4 <= H and H <= 7:
  print(7)
else:
  for i in range (1,44):
    if 2**(i-1)<H and H <2**(i):
      print(2**(i)-1)
    else:
      pass

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
#!python3.4.3

import math

h = int(input())
x = math.floor(h/2)
n = 2
count = n
while x > 1:
    x = math.floor(x/2)
    n = n*2
    count += n
    
print(count+1)

Submission status: Wrong Answer

Solution code:
H=int(input())
A=1
if H==1:
    print(1)
else:
    while H>=A:
        A*=2

Submission status: Wrong Answer

Solution code:
H = int(input())
if H==1:
  print(1)
elif 2 <= H and H <= 3:
  print(3)
elif 4 <= H and H <= 7:
  print(7)
else:
  for i in range (1,43):
    if 2**(i-1)<H and H <2**(i):
      print(2**(i)-1)
    else:
      pass

Submission status: Wrong Answer

Solution code:
h=int(input())
h1=h
icnt=1
for i in range(40):
    h1=h1//2
    icnt=icnt+1
    if h1<=1:
        break
    
s=2**icnt-1
print(s)

Submission status: Wrong Answer

Solution code:
H = int(input())

depth = 0

while H != 1:
  H = -(-H // 2)
  depth +=1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if H != 1 and H % 2 == 1:
    H = H+1
    print(H)
elif H == 1:
    print(1)
for x in range(H//2):
    ans += 2**x
print(ans)

Submission status: Wrong Answer

Solution code:
#python3
def main():
    h = int(input())
    n = h//2 + 1
    print(pow(2, n)-1)
main()

Submission status: Wrong Answer

Solution code:
import math
H = 4

l = 1
num = 0

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

print(num)

Submission status: Wrong Answer

Solution code:
n=int(input())
z=0
while n!=0:
  if n%2==0:
    z+=n
    n=n//2
  else:
    z+=n-1
    n=n//2
print(z)

Submission status: Wrong Answer

Solution code:
import math

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

Submission status: Wrong Answer

Solution code:
def pascal_monsters(n):
    return 1 if n <= 1 else n + pascal_monsters(n // 2)

Submission status: Wrong Answer

Solution code:
H=int(input())
ans=1
bycount=0
count=0
byby=0
if H==1:
    ans=1
    print(ans)
while H>1:
    H=int(H/2)
    bycount+=1

    if H==1:
        break
while bycount!=0:
    ans+=2**bycount
    bycount=bycount-1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
h = int(input())
cnt = 0
s = 0

for i in range(100):
    h = int(h/2)
    cnt += 1
    if h == 1:
        break

for j in range(cnt+1):
    s += 2 ** j

print(s)

Submission status: Wrong Answer

Solution code:
#D
import math
i = int(input())
low = 0
high = 45
for _ in range(10):
    l = 2**low
    h = 2**high
    m = 2**((low+high)/2)
    if i < m:
        high = (low+high)/2
    else:
        low = (low+high)/2
tmp = math.floor(high) + 1
print((2**tmp)-1)

Submission status: Wrong Answer

Solution code:
n=int(input())
z=0
while n>0:
  z+=n
  n=n//2
print(z)

Submission status: Wrong Answer

Solution code:
h = int(input())

ch=1
total=1

while 1:
    if h <= ch:
        break
    else:
        ch*=2
        total+=1

print(ch*2-1)

Submission status: Wrong Answer

Solution code:
H = int(input())
ans = []
for i in range (1,43):
  if 2**(i-1)<H and H <2**(i):
    for j in range (0,i):
      ans.append(2**j)
    else:
      pass
print(sum(ans))

Submission status: Wrong Answer

Solution code:
H = int(input())
#H = 10
#K = 1
#N = 3
#An = [4,1,5]

import numpy as np

cnt=0
for i in range(1000):
    if H<2**(i+1):
        break
    else:
        cnt+=1
        
#import math

if cnt ==0:
    break_cnt= 0
else:    
    break_cnt = np.sum([i**2 for i in range(cnt)])
    
kill_cnt = 2**cnt 

print(kill_cnt + break_cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def solve(H: int):
    ans = 2 ** f(H) - 1
    print(ans if ans > 0 else 1)
    return


def f(H, dep=1):
    half_h = H // 2
    dep += 1
    return f(half_h, dep) if half_h > 1 else dep


# 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: Wrong Answer

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

Submission status: Wrong Answer

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

print(math.floor(math.log(H, 2)))

Submission status: Wrong Answer

Solution code:
h = int(input())

m =1
cnt=0
if h <1:
    print(1)

elif h <=3:
    print(3)
else:
    while h >3:
        h = h //2
        cnt+=m
        m = m*2


    cnt=cnt+m*3
    print(cnt)

Submission status: Wrong Answer

Solution code:
i=int(input())
nest=1
a=0
p=i
if p==1:
  print(1)
for k in range(50):
  nest+=1
  p=p//2
  if p==1:
    break
a=(2**nest)-1
print(a)

Submission status: Wrong Answer

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


def solve(H: int):
    print(2 ** f(H) - 1)
    return


def f(H, dep=1):
    half_h = H // 2
    dep += 1
    return f(half_h, dep) if half_h > 1 else dep


# 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: Wrong Answer

Solution code:
import sys
import math

sys.setrecursionlimit(1000000000)

def dfs(hit):
    if (hit <= 1):
        return 1
    else:
        return 1 + dfs(hit / 2) + dfs(hit / 2)

H, = list(map(int, input().split()))
print(dfs(H))

Submission status: Wrong Answer

Solution code:
import math
h = int(input())
cnt=0
while True:
 cnt+=1
 h=math.floor(h/2)
 if (h/2) < 1:
  cnt+=1
  break
sum=0
for i in range(cnt):
 sum=sum + (2**i)
if h == 1:
 print(1)
else:
 print(sum)

Submission status: Wrong Answer

Solution code:
h = int(input())
tem = 1
while h/2 > 1:
    tem+=1
    h = h/2
result = 1
print("tem"+str(tem))
for i in range(1,tem+1):
    result += 2**i
print(result)

Submission status: Wrong Answer

Solution code:
i=int(input())
nest=1
a=0
p=i
for k in range(50):
  nest+=1
  p=p//2
  if p==1:
    break
a=(2**nest)-1
print(a)

Submission status: Wrong Answer

Solution code:
n=int(input())
z=0
while n!=0:
  z+=n
  n=n//2
print(z)

Submission status: Wrong Answer

Solution code:
import math
h = int(input())
cnt  = 0
if h == 2:
    print(3)
for i in range(h):
    if h == 0:
        print(2**(cnt) - 1)
        break
    h = math.floor(h/2)
    cnt += 1

Submission status: Wrong Answer

Solution code:
H=int(input())
ans=1
bycount=1
count=0
byby=0
if H==1:
    ans=1
    print(ans)
while H>1:
    H=int(H/2)
    bycount+=1
    if count==0:
        count+=1
    if count>0:
        byby+=1
    if H==1:
        break

ans=1+byby*bycount
print(ans)

Submission status: Wrong Answer

Solution code:
h = int(input())

import math

if h == 1:
    print(1)

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

    gsum = 1

    for x in range(n_attacks + 1):
        gsum += 2 ** (x + 1)
        
    print(gsum)

Submission status: Wrong Answer

Solution code:
h = int(input())

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

cnt=cnt+m*3
print(cnt)

Submission status: Wrong Answer

Solution code:
n=int(input())
z=0
while n!=0:
  z+=n//2
  n=n//2
print(z)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
H = int(input())

print((H*2) - 1)

Submission status: Wrong Answer

Solution code:
#D
import math
i = int(input())
low = 0
high = 45
for _ in range(40):
    l = 2**low
    h = 2**high
    m = 2**((low+high)/2)
    if i < m:
        high = (low+high)/2
    elif m <= i:
        low = (low+high)/2
tmp = math.floor(high) + 1
print((2**tmp)-1)

Submission status: Wrong Answer

Solution code:
H=int(input())
z=0
while H==0:
  if H%2==0:
    z+=(H//2)
    H=H//2
  else:
    z+=(H//2)
    H=H//2
print(z)

Submission status: Wrong Answer

Solution code:
from math import ceil

h = int(input())

ans = 1
i = 0
while h > 1:
    i += 1
    h = ceil(h/2)
for k in range(1, i+1):
    ans += 2**k

print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin

def attack(h):
    f = {}
    n = 1
    while (h // 2 > 1):
        h =  h // 2
        n += 1
    for i in range(n):
        f[i] = 0
    f[0] = 1
    for i in range(1, n + 1):
        f[i] = f[i-1] * 2 + 1
    return f[n]

if __name__ == '__main__':
    h = int(stdin.readline().rstrip())
    print(attack(h))

Submission status: Wrong Answer

Solution code:
h = int(input())
ans = [1 for i in range(h)]
for i in range(1,h):
    ans[i] = ans[i//2] * 2 + 1
print(ans[-1])

Submission status: Wrong Answer

Solution code:
from math import ceil

h = int(input())

ans = 1
i = 0
while h > 1:
    i += 1
    h = ceil(h/2)
print(i)
for k in range(1, i+1):
    ans += 2**k

print(ans)

Submission status: Wrong Answer

Solution code:
H = int(input())
h = H
count = 0

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

Submission status: Wrong Answer

Solution code:
h = int(input())

attack = 1
while h > 0 :
    h = h // 2
    print(h)
    attack *= 2

print(attack - 1)

Submission status: Wrong Answer

Solution code:
h = int(input())

count = 0
tmp = h

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

while True:
    tmp = tmp // 2
    count = count + 1
    if tmp == 1:
        break
ans = 0
for i in range(count):
    ans = ans + 2**i
ans = ans + h
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
H = int(input())
base = 0
while 2 ** base < H:
    base = base + 1

if H % 2 != 0:
    base = base - 1

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

Submission status: Wrong Answer

Solution code:
import math
h=int(input())
cnt=1
ans = 1
for i in range(h):
    h= math.floor(h/2)
    if h <= 1:
        cnt += i
        break
for j in range(1,cnt+1):
    ans+= 2**j
print(ans)

Submission status: Wrong Answer

Solution code:
a=int(input())
b=[2**n-1 for n in range(42)][-1::-1]
for i in range(1,len(b)):
    if b[i]<=a:
        print(b[i-1])
        break

Submission status: Wrong Answer

Solution code:
def main():
    h = int(input())
    cnt = 0
    ans = 0
    tmp = 1
    #
    # for i in range(1,h):
    #     if h % 2 == 0:
    #         h //= 2
    #     else:
    #         break

    for _ in range(h*2):
        h //=2

        cnt += tmp
        tmp *= 2
        if h==1:
            break

    print(cnt+tmp)
if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

if n % 2 == 1:
    n -= 1

if n % 2 == 0:
    a = 2**int(n/2+1) - 1

print(a)

Submission status: Wrong Answer

Solution code:
h=int(input())
count=1
ans=1
v=h
while True:
    temp=int(v//2)
    #count=count*2
    #ans+=count
    if temp<=1:
        count=count*2
        ans+=count
        break
    v=temp
    count=count*2
    ans+=count
    
print(ans)

Submission status: Wrong Answer

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

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

total = 0
total = (1 - (2**(count + 1)))/(1 - 2)
print(total)

Submission status: Wrong Answer

Solution code:
from __future__ import print_function

import sys
input = sys.stdin.readline


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


# import re
# import array
# import copy
# import functools
# import operator

import math
# import string
import fractions
# from fractions import Fraction
from fractions import gcd

# import collections
# import itertools
# import bisect

# 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

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


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


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


# import random
# import time


def main():
    h = int(input().strip())
    t_height = math.log(h, 2)
    # eprint("t_height ", end=": ")
    # eprint(math.ceil(t_height))
    t_height = math.ceil(t_height)
    print(2**(t_height) - 1)
    return


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    h = int(input())
    cnt = 0
    ans = 0
    tmp = 1
    #
    # for i in range(1,h):
    #     if h % 2 == 0:
    #         h //= 2
    #     else:
    #         break

    for _ in range(h):
        h //=2

        cnt += tmp
        tmp *= 2
        if h==1:
            break

    print(cnt+tmp)
if __name__=='__main__':
    main()

Submission status: Wrong Answer

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