Problem:

２の累乗

　

与えられた数を、それ以下の数の中で最大の$2$の累乗に変換してください。たとえば、$2$や$3$ならば$2^1=2$に変換してください。同様に$4$,$5$,$6$,$7$ならば$2^2=4$に、$8$,$9$,$10$,$11$,...,$15$ならば$2^3=8$に変換してください。

  与えられた数を、その数以下の数の中で最大の$2$の累乗に変換するプログラムを作成せよ。

入力

  入力は以下の形式で与えられる。

$N$

  １行に数$N$ ($2 \leq N \leq 10^6$)が与えられる。

出力

  変換した数を１行に出力する。

入出力例

入力例１

54

出力例１

32

入力例２

1024

出力例２

1024	



Sample input:
54


Sample output:
32

Submission status: Accepted

Solution code:
n=int(input())
a=10**6
for i in range(a):
    if 2**i <= n and n<2**(i+1):
        print(2**i)
        break

Submission status: Accepted

Solution code:
import math
N = int(input())
A = math.log2(N)
print(2**(math.floor(A)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def p(x):
  answer = True
  while(x > 1):
    if x % 2 == 0:
      x =  x // 2
    else:
      answer = False
      break
  return answer

N = int(input())
for i in range(N,0,-1):
  if p(i) == True:
    print(i)
    break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
i = 1
while True :
    if n < i * 2 :
        break
    i *= 2
print(i)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = len(bin(n)) - 1
print(2 ** (l - int(bin(n).find("1"))))

Submission status: Accepted

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

if 2**1<=N<2**2:
    print(2**1)
elif 2**2<=N<2**3:
    print(2**2)
elif 2**3<=N<2**4:
    print(2**3)
elif 2**4<=N<2**5:
    print(2**4)
elif 2**5<=N<2**6:
    print(2**5)
elif 2**6<=N<2**7:
    print(2**6)
elif 2**7<=N<2**8:
    print(2**7)
elif 2**8<=N<2**9:
    print(2**8)
elif 2**9<=N<2**10:
    print(2**9)
elif 2**10<=N<2**11:
    print(2**10)
elif 2**11<=N<2**12:
    print(2**11)
elif 2**12<=N<2**13:
    print(2**12)
elif 2**13<=N<2**14:
    print(2**13)
elif 2**14<=N<2**15:
    print(2**14)
elif 2**15<=N<2**16:
    print(2**15)
elif 2**16<=N<2**17:
    print(2**16)
elif 2**17<=N<2**18:
    print(2**17)
elif 2**18<=N<2**19:
    print(2**18)
elif 2**19<=N<2**20:
    print(2**19)
else:
    print(2**20)

Submission status: Accepted

Solution code:
#標準入力とリストの初期化
i = int(input())
j = 2
kei = 1

#2をかけて入力値を超えたときの前の数を出力する
while True:
    if j <= i < j * 2:
        print(j)
        break
    else:j = j * 2

Submission status: Accepted

Solution code:
n = int(input())

ans = 1
while(ans <= n):
    ans = ans * 2

print(ans // 2)

Submission status: Accepted

Solution code:

N = int(input())

ans = 2

while(ans <= N):
    ans = ans * 2
    
print(ans // 2)

Submission status: Accepted

Solution code:
def getNum(n):
    num = 1
    while(2 ** num <= n):
        num += 1
    return num - 1
a = int(input())
print(2 ** getNum(a))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
	
	n = int(input())

	for i in range(21):
		s = pow(2,i)
		if n < s:
			if i == 0:
				print(1)
			else:
				print(pow(2,i-1))
			break
		elif n == s:
			print(pow(2,i))
			break

Submission status: Accepted

Solution code:
n = int(input())
num = 2

while n > num: 
    num *= 2
    
if num > n:
    num /= 2
    


print(int(num))

Submission status: Accepted

Solution code:
from math import log2
print(2**int(log2(int(input()))))

Submission status: Accepted

Solution code:
a = 1
n = int(input())
while True:
  if a * 2 > n:
    print(a)
    exit()
  a *= 2

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
ret = 1
i = 0
while ret <= n:
    ret = 2**i
    i += 1
print(ret//2)

Submission status: Accepted

Solution code:
x = int(input())
s = 1
while s <= x:
    s *= 2
print(s//2)

Submission status: Accepted

Solution code:
n = int(input())
count = 0
for i in range(1,n+1):
    if n < 2**(i):
        count = 2**(i-1)
        break
print(count)

Submission status: Accepted

Solution code:
import math

N = int(input())

print(2 ** int(math.log2(N)))

Submission status: Accepted

Solution code:
n=int(input())
i=0
while n>0:
	i+=1
	n//=2
print(pow(2,i-1))

Submission status: Accepted

Solution code:
n = int(input())
idx = 1
while True:
    h = 2 ** idx
    if h > n:
        print(2 ** (idx - 1))
        exit()
    idx += 1

Submission status: Accepted

Solution code:
A = int(input())
anw = 1
while 1:
    if anw * 2 <= A: anw *= 2
    else: break
print(anw)

Submission status: Accepted

Solution code:
N = int(input())
n = 2
while n<N:
  n = n * 2 
if n<=N:print(int(n))
else : print(int(n/2))

Submission status: Accepted

Solution code:
n = int(input())
c = 0
while n > 1 :
    n = n >> 1
    c = c + 1
print( 1<<c )

Submission status: Accepted

Solution code:
n = int(input())
s = 1
while s <= n:
    s *= 2
print(s//2)

Submission status: Accepted

Solution code:
a = int(input())
b = 2
while True:
    b*=2
    if b == a:
        print(b)
        break
    elif b > a:
        b/=2
        b = int(b)
        print(b)
        break

Submission status: Accepted

Solution code:
N = int(input())
count = 1
while count <= N:
    count *= 2
print(round(count/2))

Submission status: Accepted

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

while True:
    if b*2 <= n:
        b *= 2
    else:
        break

print(b)

Submission status: Accepted

Solution code:
n = int(input())
ans = 1
while ans*2<=n: ans *= 2
print(ans)

Submission status: Accepted

Solution code:
ans = 1
n = int(input())
while ans <= n:
    ans *= 2
ans = ans//2
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
for i in range(n):
    if 2**i<=n<2**(i+1):
        print(2**i)
        break