Problem:
 Score : 200 points    Problem Statement Takahashi loves numbers divisible by 2 .  You are given a positive integer N . Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.  Here, the number of times an integer can be divisible by 2 , is how many times the integer can be divided by 2 without remainder.  For example,   6 can be divided by 2 once: 6 -> 3 .  8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1 .  3 can be divided by 2 zero times.       Constraints  1 ≤ N ≤ 100         Input Input is given from Standard Input in the following format:  N       Output Print the answer.        Sample Input 1 7      Sample Output 1 4  4 can be divided by 2 twice, which is the most number of times among 1 , 2 , ..., 7 .       Sample Input 2 32      Sample Output 2 32       Sample Input 3 1      Sample Output 3 1       Sample Input 4 100      Sample Output 4 64

Solution (Python):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
max_num = 0
ans = 1
for i in range(1, N+1):
    tmp = i
    num = 0
    while tmp % 2 == 0:
        num += 1
        tmp /= 2
    if num > max_num:
        ans = i
        max_num = num

print(ans)

Solution (Python):
n = int(input())
print(max( [2**i if 2**i <= n else 1 for i in range(1,n+1)]))

Solution (Python):
n = int(input())
ans = 0
mul = 1
while mul <= n:
    ans += 1
    mul *= 2
print(mul // 2)

Solution (Python):
N = int(input())

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

i = 0
while 2 << i <= N:
    i += 1

print(2 << (i - 1))

Solution (Python):
N=int(input())
for a in [1,2,4,8,16,32,64]:
    if N>=a:
        b=a
print(b)

Solution (Python):
N=int(input())
ans=[1,2,4,8,16,32,64]
arr=[]
for a in ans:
    if N >= a:
        arr.append(a)
print(arr[-1])

Solution (Python):
n=int(input())
c=0
while 2**c<=n:
    c+=1
print(2**(c-1))

Solution (Python):
n=int(input())
ans=1
for i in range(7):
    if 2**i<=n:ans=2**i
print(ans)

Solution (Python):
n=int(input())
ans=1
for i in range(100):
    if 2**i<=n:ans=2**i
print(ans)

Solution (Python):
N = int(input())
if N == 1:
    print(1)
    exit(0)
elif N == 2:
    print(2)
    exit(0)
for i in range(N):
    if 2 ** i > N:
        print(2 ** (i - 1))
        exit(0)

Solution (Python):
N = int(input())
ans = 1
while 2*ans <= N:
    ans = ans*2
print(ans)

Solution (Python):
n = int(input())

for i in range(7):
  if n >= 2**i:
    ans = 2**i
print(ans)

Solution (Python):
N = int(input())

for i in range(50):
    if 2**i > N:
        break
print(2**(i-1))

Solution (Python):
n = int(input())

ret = -float('inf')
ans = None
for i in range(1, n + 1):
    cnt = 0
    j = i
    while j % 2 == 0:
        cnt += 1
        j //= 2
    if ret < cnt:
        ret = cnt
        ans = i
print(ans)

Solution (Python):
N = int(input())
if N>=64:
  print(64)
elif N>=32:
  print(32)
elif N>=16:
  print(16)
elif N>=8:
  print(8)
elif N>=4:
  print(4)
elif N>=2:
  print(2)
else:
  print(1)

Solution (Python):
n = int(input())
for i in range(7):
  if n < 2**i:
    print(2**(i-1))
    exit()
print(2**6)

Solution (Python):
def count_devide2(x):
    cnt = 0
    while x % 2 == 0:
        cnt += 1
        x /= 2 
    return cnt

n = int(input())
Max = 0
for i in range(1,n+1):
    if Max <= count_devide2(i):
        ans = i
        Max = count_devide2(i)
print(ans)

Solution (Python):
import math
print(2**math.floor(math.log(int(input()))/math.log(2)))

Solution (Python):
def main():
    N = int(input())
    max_count = 0
    max_i = 1
    for i in range(2, N+1):
        count = 0
        j = i
        while j > 0 and j % 2 == 0:
            j = j // 2
            count += 1
        if count > max_count:
            max_count = count
            max_i = i
    return max_i

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

Solution (Python):
n=int(input())
print(64 if n>63 else 32 if n>31 else 16 if n>15 else 8 if n>7 else 4 if n>3 else 2 if n>1 else 1)

Solution (Python):
def how_many_times_divisible(n):
  ans=0
  while n%2==0:
    n=n/2
    ans=ans+1
  return ans

N=int(input())
x=max(map(how_many_times_divisible,range(1,N+1)))
print(2**x)

Solution (Python):
n=int(input())
m=1
while 2**m<=n:
  m+=1
else:
  print(2**(m-1))

Solution (Python):
n=int(input())
count=1
while count<=n:
    count=2*count
else:
    print(int(count/2))

Solution (Python):
n=int(input())
p=1
while p<=n:
    p*=2
print(p//2)

Solution (Python):
N = int(input())

ans = 1
for i in range(7):
    if 2**i <= N:
        ans = 2**i
    else:
        break

print(ans)

Solution (Python):
n = int(input())
a = []
b=[]

for i in range(1,n+1):
  a.append(i)
count = 0


for i in range(1,n+1):
  
  count = 0
  while True:
    if (a[i-1]%2) == 0:
      count += 1
      a[i-1] = a[i-1]/2
      
    else:
      break
  b.append(count)


c =max(b)
print(b.index(c)+1)

Solution (Python):
n = int(input())

ans = 1
for i in range(n):
    if ans*2 <= n:
        ans = ans*2
    elif ans*2 > n:
        break

print(ans)

Solution (Python):
n=int(input())
ans=0
while 2**ans <=n:
  ans+=1
print(2**(ans-1))

Solution (Python):


num = int(input())

def count_divide(target_int):
    evaluating = target_int
    divide_count = 0
    while True:
        if evaluating == 0:
            break
        if evaluating % 2 == 0:
            evaluating /= 2
            divide_count += 1
        else:
            break
    return divide_count
    
result = {}

for i in range(1, num + 1):
    
    result[i] = count_divide(i)


sorted = sorted(result.items(), key = lambda x: x[1], reverse = True)
print(sorted[0][0])

Solution (Python):
n = int(input())
a = 1
cnt = 0
while True:
    a *= 2
    if n >= a:
        cnt += 1
    else:
        a /= 2
        break
print(int(a))

Solution (Python):
N = int(input())
i = 0
ans = 0
while True:
    if N >= 2**i:
        i += 1
        pass
    elif N == 1 or N <= 2**i:
        ans += 2**(i-1)
        break
print(ans)

Solution (Python):
n = int(input())
ans = 1
while n >= ans:
         ans *= 2
else:
         ans = ans // 2
         print(ans)

Solution (Python):
n=int(input())

for i in range(10):
  if n<2**i:
    print(2**(i-1))
    break

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

Solution (Python):
N = int(input())
ans = 1
prev = 0
for i in range(1,N+1):
  counter = 0
  while i % 2 == 0:
    i /= 2
    counter += 1
  if prev < counter:
    ans = int(i * (2**counter))
    prev = counter
    
print(ans)

Solution (Python):
print(1<<int(input()).bit_length()-1)

Solution (Python):
n = int(input())
ans = 1
divmax = 0
for i in range(2,n+1,2):
    cnt = 0
    cur = i
    while not cur&1:
        cnt += 1
        cur //= 2
    if divmax < cnt:
        divmax = cnt
        ans = i
print(ans)

Solution (Python):
print(2**(len(bin(int(input())))-3))

Solution (Python):
n = int(input())
if n>=64:
  print(64)
elif n >=32:
  print(32)
elif n >=16:
  print(16)
elif n >=8:
  print(8)
elif n >=4:
  print(4)
elif n >=2:
  print(2)
else:
  print(1)

Solution (Python):
N = int(input())
for i in reversed(range(8)):
  if N >= (1<<i):
    r = 1<<i
    print(r)
    exit()

Solution (Python):
n = int(input())
for i in range(7):
    if 2**(6-i)<= n:
        print(2**(6-i))
        break

Solution (Python):
N = int(input())
num = 1
for i in range(1, 7):
    if N >= 2 ** i:
        num = 2 ** i
print(num)

Solution (Python):
n = int(input())
for i in range(1,10):
    if 2 ** i > n:
            print(2**(i-1))
            exit()

Solution (Python):
n = int(input())
count = 0
while 2**count <= n:
    count = count + 1
print(2**(count-1))

Solution (Python):
N = int(input())
a=1
for i in range(6):
  if 2**(i+1)<=N:
    a=2**(i+1)
print(a)

Solution (Python):
n=int(input())
a=2
b=0
while n>=a**b:
    b+=1
else:
    print(a**(b-1))

Solution (Python):
n=int(input())
ans=1
for i in range(7):
    if 2**i<=n:ans=2**i
print(ans)

Solution (Python):
N = int(input())

ans = 1
while ans * 2 <= N:
    ans *= 2

print (ans)

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

Solution (Python):
from math import log2
n = int(input())
ans = 0
for i in range(1, n + 1):
  if log2(i) % 1 == 0:
    ans = max(i, ans)
print(ans)

Solution (Python):


N = int(input())

for i in range(100):
    if N < 2 ** i:
        print(2 ** (i - 1))
        exit()

Solution (Python):
n=int(input())
ans=1
for i in range(7):
    if 2**i<=n:ans=2**i
print(ans)

Solution (Python):
N = int(input())
a = 1
for i in range(7):
    if 2**i <= N:
        a = 2**i
print(a)

Solution (Python):
N = int(input())
a = 1
if N == 1:
    print(1)
else:
    while N >= a:
        a *= 2
    print(a//2)

Solution (Python):
n = int(input())
t = 1
while True:
    t *= 2
    if t > n:
        print(t // 2)
        exit()

Solution (Python):
n = int(input())
cnt = 0
while True:
    if 2**(cnt + 1) > n:
        break
    cnt += 1
print(2**cnt)

Solution (Python):
print(2**(len(bin(int(input())))-3))

Solution (Python):
A = int(input())

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

print(ans // 2)

Solution (Python):
A = int(input())
ans, max_count = 0, 0

if A == 1:
    print(1)
else:
    for a in range(1, A + 1):
        count = 0
        tmp = a
        while True:
            if tmp % 2 != 0:
                if count > max_count:
                    max_count = count
                    ans = a
                break

            tmp /= 2
            count += 1

    print(ans)

Solution (Python):
def two(n):
  count=0
  while n%2==0:
    count+=1
    n//=2
  return count

n=int(input())

ans=0
t=0
for i in range(1, n+1):
    ttt=two(i)
    if ttt>=t:
        ans=i
        t=ttt
        

print(ans)

Solution (Python):
N = int(input())

def solver(num):
  ctr = 0
  while num % 2 == 0:
    num = int(num / 2)
    ctr += 1
  return ctr

ct = 0
ans = 0

for i in range(1,N+1):
  if solver(i) >= ct:
    ans = i
    ct = solver(i)

print(ans)

Solution (Python):
res = int(input())
while res != (res & (-res)):
  res -= res & (-res)
print(res)

Solution (Python):
N = int(input())
num_list=[]
for num in range(1,N+1):
  counter=0
  while True:
    if int(num/2)==num/2:
      num/=2
      counter+=1
    else:
      break
  num_list.append(counter)
print(num_list.index(max(num_list))+1)

Solution (Python):
x=1
d=0
for i in range(int(input())):
    k=i+1
    while k%(2**(d+1))==0:
        d+=1
        k=k//2
        x=i+1

print(x)

Solution (Python):
n=int(input())
a=0
while 2**(a+1)<=n:
    a+=1
print(2**a)

Solution (Python):



def two_factor(x):
    cnt = 0
    while x % 2 == 0:
        cnt += 1
        x //= 2
    return cnt


N = int(input())
a = list(map(two_factor, range(1, N + 1)))
max_cnt = max(a)
print(a.index(max_cnt) + 1)

Solution (Python):
n = int(input())

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

Solution (Python):
N=int(input())
t=1
while t*2<=N:
    t*=2
print(t)

Solution (Python):
n = int(input())
for i in range(7) :
    if (2**i) <= n :
        ans = 2**i
print(ans)

Solution (Python):
n = int(input())
x = 1
while x <= n:
    x *= 2
print(int(x / 2))

Solution (Python):
n = int(input())

ans = 1

while ans < n:
	ans = ans * 2

if ans > n:
	ans = ans/2

print(int(ans))

Solution (Python):
n = int(input())
ans = 1

for i in range(7):
  if n >= 2 ** i:
    ans = 2 ** i
print(ans)

Solution (Python):
N = int(input())

ret = 1
while ret * 2 <= N :
    ret *= 2
    
print(ret)

Solution (Python):
n=int(input())
for i in range(7):
  if 2**i<=n<2**(i+1):
    print(2**i)
    exit()

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

Solution (Python):
N=int(input())

count=0
for i in range(0,N):
    if 2**i > N:
        count=i-1
        break
print(2**count)

Solution (Python):

N = int(input())


cand = [2**e for e in range(0,7)]
res = max([e for e in cand if N - e >= 0])


print(res)

Solution (Python):
N = int(input())
l = set(range(1, N + 1))
z = {2 ** n for n in range(7)}
print(max(l&z))

Solution (Python):
n = int(input())

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

print(ans)

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

Solution (Python):
print(2**(len(bin(int(input())))-3))

Solution (Python):
n = int(input())
a = [2**i for i in range(10) if 2**i <= n]
print(max(a))

Solution (Python):
num = int(input())


if num == 1:
    print(1)
elif num == 2 | 3:
    print(2)
elif 4 <= num <= 7:
    print(4)
elif 8 <= num <= 15:
    print(8)
elif 16 <= num <= 31:
    print(16)
elif 32 <= num <= 63:
    print(32)
else:
    print(64)

Solution (Python):


def main():

    N = int(input())
    count = 0
    ansList = []

    for i in range(1,N+1):
        count = 0
        while(True):
            if i%2==0:
                count += 1
                i /= 2
            else:
                ansList.append(count)
                break

    print(ansList.index(max(ansList))+1)

    



    


if __name__== "__main__":
    main()

Solution (Python):
N = int(input())
exp = 0
 
while N >= 2:
  N = N // 2
  exp += 1
  
print(2 ** exp)

Solution (Python):
N = int(input())
p = 0
while(N >=2):
    N = N //2 
    p += 1
print(2**p)

Solution (Python):
n = int(input())
a = [64, 32, 16, 8, 4, 2, 1]

for i in a:
    if i <= n:
        print(i)
        break

Solution (Python):
N = int(input())
ans = 0
while(N>=2):
    N = N//2
    ans += 1
print(2**ans)

Solution (Python):
n = int(input())
l = [1, 2, 4, 8, 16, 32, 64, 128]
i = 0
while l[i] <= n:
  i += 1
else:
  print(l[i-1])

Solution (Python):
n = int(input())
if n < 2:
  print(1)
elif n < 4:
  print(2)
elif n < 8:
  print(4)
elif n < 16:
  print(8)
elif n < 32:
  print(16)
elif n < 64:
  print(32)
else:
  print(64)

Solution (Python):
N = int(input())
x = []
for i in range(1, N + 1):
    cnt = 0
    while i % 2 == 0:
        a = i
        i /= 2
        cnt += 1
    x.append(cnt)


print(x.index(max(x)) + 1)

Solution (Python):
n=int(input())
print(64 if n>=64 else 32 if n>=32 else 16 if n>=16 else 8 if n>=8 else 4 if n>=4 else 2 if n>=2 else 1)

Solution (Python):
N=int(input())
max_count=0
answer=1
for num_x in range(1,N+1):
    num=num_x
    count=0
    flag=True
    while(flag):
        if num%2==0:
            count+=1
            num=num/2
        else:
            flag=False
    if count>max_count:
        answer=num_x
        max_count=count
print(answer)

Solution (Python):
n = int(input())
cnt = 0
while True:
    if 2 ** (cnt + 1) > n:
        print(2 ** cnt)
        exit(0)
    cnt += 1

Solution (Python):
N = int(input())
cnt = 0
answer = 1
answer_cnt = 0

for i in range(1, N + 1):
    cnt = 0
    m = i
    while m & 1 == 0:
        m >>= 1
        cnt += 1
    if cnt > answer_cnt:
        answer_cnt = cnt
        answer = i
print(answer)

Solution (Python):
print(2 ** (len(bin(int(input())))-3))

Solution (Python):
n = int(input())
print(2**(len(bin(n))-3))

Solution (Python):
N = int(input())
L = [(N,0),(1,0), (2,1), (4,2), (8,3), (16,4), (32,5), (64,6),(128,7)]
sorted_L = sorted(L,key=lambda x:x[0])
for i,j in enumerate(sorted_L):
  if j[0] == N:
    if sorted_L[i][0] == sorted_L[i+1][0]:
      print(sorted_L[i][0])
      break
    else:
      print(sorted_L[i-1][0])
      break

Solution (Python):
N = int(input())

a = []
for i in range(1,N + 1):
  count = 0
  while True:
    if i % 2 == 1:
      break
    else:
      i /= 2
      count += 1
  a.append(count)
print(a.index(max(a)) + 1)

Solution (Python):
N  = int(input())

x = []
for i in range(1,N+1):
  counter = 0
  while i % 2 == 0:
    a = i
    i/=2
    counter +=1
  x.append(counter)
    

print(x.index(max(x))+1)

Solution (Python):
N = int(input())

tnum = 0
iter_num = 0

for i in range(N):
    res = 0
    num = i+1
    while num % 2 == 0:
        num /= 2
        res += 1
    if iter_num <= res:
        iter_num = res
        tnum = i+1

print(tnum)

Solution (Python):
N = int(input())
print(2**(len(bin(N))-3))

Solution (Python):
n = int(input())
print(2**(len(bin(n))-3))

Solution (Python):
n = int(input())
s = [1 << i for i in range(7) if 1 << i <= n]
print(s[-1])

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

Solution (Python):
N=int(input())
n=1
while True:
  if n*2>N:
    break
  else:
    n*=2
print(n)

Solution (Python):
import math
print(2**int(math.log2(int(input()))))

Solution (Python):
print(2**(len(bin(int(input())))-3))

Solution (Python):
n=int(input())
i=0
while 2**i<100:
    if n<2**(i+1):
        print(2**(i))
        break
    i+=1

Solution (Python):

n = int(input())
ans = 1

for i in range(7):
    if 2**i <= n:
        ans = 2**i

print(ans)

Solution (Python):

n = int(input())
ptn = []
i = 1
while True:
    ptn.append(i)
    i *= 2
    if i > 100*2:
        break

before = 0
for i in ptn:
    if n < i:
        print(before)
        exit()

    before = i

Solution (Python):
n=int(input())
cl=[]
for i in range(1,n+1) :
  count=0
  temp=i
  while(True) :
    if temp % 2== 0:
      temp=temp/2 
      count+=1
    else :
      break
  cl.append(count)
  
print((cl.index(max(cl)))+1)

Solution (Python):
Num = int(input())
Count = 0
Count_result = 0
result = 0
a = 0

for i in range(1,Num+1):
    a = i
    while a % 2 == 0  and  a / 2 > 0:
        a /= 2
        Count += 1
    if Count_result < Count:
        Count_result = Count
        result = i
    Count = 0
if Num == 1 :
    result = 1
print (result)

Solution (Python):
def counter(num, c=0):
    if num % 2 != 0:
        return c
    c = counter(num/2, c+1)
    return c

N = int(input())
result = 1
max_num = 0
for i in range(2, N+1, 2):
    temp = counter(i)
    if max_num < temp:
        result = i
        max_num = temp
print(result)

Solution (Python):
n=int(input())
f=0
fn=0
for i in range(1,n+1): 
    c=0
    s=i
    while s%2==0: 
        s=s//2
        c+=1
    
    if c>=f:
        fn=i
        f=c
print(fn)

Solution (Python):
print(2**(len(bin(int(input())))-3))

Solution (Python):
n = int(input())
ans = 1
for i in range(7):
    if 2**i <= n:
        ans = 2**i
print(ans)

Solution (Python):
N = int(input())

a = 1
while (a<=N):a*=2
print (a//2)

Solution (Python):

import sys
import math
INF = float("inf")


def solve(N: int):
    m, div = 1, 0
    for i in range(1, N+1):
        b = int(math.log2(i & -i))
        if b > div:
            m = i
            div = b
    print(m)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
twos = [2 ** i for i in range(8)]
for t in reversed(twos):
    if  t <= N:
        print(t)
        exit()

Solution (Python):
print(2**(len(bin(int(input())))-3))

Solution (Python):
N = int(input())
l = [2 ** i for i in range(6, -1, -1)]

for i in l:
    if N >= i:
        print(i)
        exit()

Solution (Python):
a = int(input())
b = 0
c = []
for i in range(1,a+1):
  while i % 2 == 0:
    b += 1
    i /= 2
  else:
    c.append(b)
    b = 0
c.sort(reverse=True)
print(2**c[0])

Solution (Python):
n = int(input())
if n < 2:
  print(1)
elif n < 4:
  print(2)
elif n < 8:
  print(4)
elif n < 16:
  print(8)
elif n < 32:
  print(16)
elif n < 64:
  print(32)
else:
  print(64)

Solution (Python):
a = int(input())

x = 1
while True:
    x *= 2
    if x > a:
        x  = x//2
        break
print(x)

Solution (Python):
N=int(input())
ans=1
while ans<=N/2:
    ans*=2
print(ans)

Solution (Python):
N = int(input())

print(2**(len(bin(N))-3))

Solution (Python):
n = int(input())
i=1
while ( i*2<= n):
        i*=2
print(i)

Solution (Python):
import sys
 
N=int(input())
 
if N==1:
  print(1)
  sys.exit()

Flag=0
nCnt=1
Tmp=2
while Flag==0:
  TmpN = N /Tmp
  if TmpN >= 2:
    Tmp *= 2
    nCnt +=1
  else:
    Flag=1

A = 2 ** (nCnt)
print(A)

Solution (Python):
n = int(input())

ans = 0
for i in range(1, n+1):
    cnt = 0
    while i%2 == 0:
        i /= 2
        cnt += 1
    ans = max(ans, cnt)
print(2**ans)

Solution (Python):
n = int(input())
cnt = 0
while True:
    cnt += 1
    if 2 ** cnt > n:
        print(2 ** cnt // 2)
        exit()

Solution (Python):
i = 1
n = int(input())
while(i * 2 <= n):
    i *= 2

print(i)

Solution (Python):
n = int(input())

a = [1,2,4,8,16,32,64]
ans = 1
for i in range(n+1):
    if i in a:
        ans = i
print(ans)

Solution (Python):
n = int(input())
ans = 1
maxcnt = 0
for i in range(1, n+1):
    cnt = 0
    now = i
    while (now % 2 == 0):
        now //= 2
        cnt += 1
    if cnt > maxcnt:
        maxcnt = cnt
        ans = i
print(ans)

Solution (Python):
n = int(input())

for i in range(8, -1, -1):
    if n >= 2 ** i:
        print(2**i)
        break

Solution (Python):
n = int(input())
res = 1
for i in range(7):
  if 2 ** i <= n:
    res = 2 ** i
  else:
    break
print(res)

Solution (Python):
N = int(input())

i = 1
while 2**i <= N:
    i += 1
ans = 2 ** (i-1)
print(ans)

Solution (Python):
res=1
maxT=0
for i in range(1,int(input())+1):
  c=i
  t=0
  while c!=1:
    if c%2==0:
      t+=1
    else:
      break
    c//=2
  if t>maxT:
    res=i
    maxT=t
print(res)

Solution (Python):
x = int(input())
cnt = 1
for i in range(100):
  cnt *= 2
  if cnt > x:
    print(int(cnt/2))
    break

Solution (Python):
n=int(input())
x=""
while n!=0:
    x=str(n%2)+x
    n=n//2
print(2**(len(x)-1))

Solution (Python):
import math
print(2**(math.floor(math.log2(int(input())))))

Solution (Python):
n = int(input())

ans = 1
maxcnt = 0
for i in range(1, n+1):
  tmp = i
  cnt = 0
  while True:
    if tmp % 2 == 0:
      tmp = tmp // 2
      cnt += 1
    else:
      break

  if maxcnt < cnt:
    ans = i
    maxcnt = cnt
      
print(ans)

Solution (Python):
n = int(input())
i = 1
while True:
    if 2 ** i > n:
        print(2 ** (i - 1))
        exit()
    i += 1

Solution (Python):
n = int(input())


list_2_jou = [2, 2**2, 2**3, 2**4, 2**5, 2**6]



list_2_jou.sort(reverse=True)

for jou in list_2_jou:
    if jou <= n:
        print(jou)
        exit()

print(1)

Solution (Python):
N = int(input())
list = list()
for i in range(1, N+1):
    count = 0
    while True:
        if i%2 == 0:
            i /= 2
            count += 1
        else:
            break
    list.append(count)

print(list.index(max(list))+1)

Solution (Python):
N = int(input())

mul2 = [2**i for i in range(7)[::-1]]

for i in mul2:
    for j in range(1, N+1):
        if j == i:
            print(i)
            exit()

Solution (Python):
n = int(input())
i = 0
while 2**i <= n:
    i += 1
print(2**(i-1))

Solution (Python):
a = int(input())
b = range(1, a + 1)
res = 1
max_cnt = 0

for index, bb in enumerate(b):
  cnt = 0
  while True:
    if bb % 2 == 0:
      bb /= 2
      cnt += 1
    else:
      break
  if cnt > max_cnt:
    max_cnt = cnt
    res = index + 1
    
print(res)

Solution (Python):
n=int(input())
import bisect
a=[1,2,4,8,16,32,64]
k=bisect.bisect_right(a,n)
print(a[k-1])

Solution (Python):
N = int(input())
num = 1
count = 0

while num <= N:
    num *= 2
    count += 1
    if num > N:
        num = int(num / 2)
        count -= 1
        break

print(num)

Solution (Python):
n = int(input())
br = []

for i in range(n + 1)[1:]:
    count = 0
    while True:
        if i % 2 == 0:
            count += 1
            i /= 2
        else:
            break
    br.append(count)

print(br.index(max(br)) + 1)

Solution (Python):
n = int(input())
li = [1,2,4,8,16,32,64]
ans = 0
for i in li:
    if i <= n:
        ans = i
print(ans)

Solution (Python):
n = int(input())
ans = []
for i in range(1,n+1):
    count = 0
    num = i
    while True:
        if num % 2 == 0:
            count += 1
        else:
            break
        num /= 2
    ans.append(count)
print(ans.index(max(ans))+1)

Solution (Python):
N = int(input())
ans = 0
maxCnt = 0

for i in range(1, N + 1):
    tmpCnt = 0
    tmp = i
    if i % 2 == 0:
        for j in range(i):
            tmp = tmp // 2
            tmpCnt += 1
            if tmp % 2 != 0:
                break
    if maxCnt <= tmpCnt:
        maxCnt = tmpCnt
        ans = i

print(ans)

Solution (Python):
n = int(input())
i=0
while 2**i <= n:
  i+=1
print(2**(i-1))

Solution (Python):

n = int(input())

for i in range(7, -1, -1):
    if 2**i <= n:
        print(2**i)
        break

Solution (Python):
N = int(input())
ans = 1
while N > ans:
  ans = ans * 2
ans = N if ans == N else ans//2
print(ans)

Solution (Python):
n = int(input())
result = 2
while result <= n:
    result = result*2
print(result//2)

Solution (Python):
n=int(input())

flag=True


for i in range(n):
    if 2**i>n:
        if flag:
            flag=False
            print(2**(i-1))
if n==1:
    print(1)

Solution (Python):
n=int(input())

flag=True


for i in range(n):
    if 2**i>n:
        if flag:
            flag=False
            print(2**(i-1))
if n==1:
    print(1)

Solution (Python):

def IsNum(x,y):
  if x % 2 == 0 :  
    y += 1
    return IsNum(int(x / 2),y)
  else:
    return y

N = int(input())

dict_num = {}
for i in range(N):
  num = i + 1
  rec = IsNum(num,0)
  dict_num[num] = rec
rec = [ num for num,v in dict_num.items() if v == max(dict_num.values())]

print(rec[0])

Solution (Python):
n = int(input())
if n>=64:
  print("64")
elif 64>n>=32:
  print("32")
elif 32>n>=16:
  print("16")
elif 16>n>=8:
  print("8")
elif 8>n>=4:
  print("4")
elif 4>n>=2:
  print("2")
else:
  print("1")

Solution (Python):
n = int(input())
if n < 2:
	print(1)
elif 2<= n < 4:
	print(2)
elif 4 <= n < 8:
	print(4)
elif 8 <= n < 16:
	print(8)
elif 16 <= n < 32:
	print(16)
elif 32 <= n < 64:
	print(32)
else:
	print(64)

Solution (Python):

import sys, math, fractions, itertools


def solve(N: int):
    k = 1
    while(N >= k*2):
        k *= 2
    print(k)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  
    solve(N)

if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
nums = [64, 32, 16, 8, 4, 2]
for num in nums:
  if N >= num:
    print(N-N%num)
    exit()
print(1)

Solution (Python):
N = int(input())

for i in range(8):
  if N < 2**i:
    print(2**(i-1))
    break

Solution (Python):


def main(N):
    ans = 0
    for i in range(1,N+1):
        count = 0
        n = i
        while(n%2==0):
            count += 1
            n /= 2
        ans = max(ans, count)
    
    print(2**ans)
            
    

if __name__ == '__main__':
    N = int(input())
    main(N)

Solution (Python):

import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import math
import itertools
 




 
def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
 
def main():
    N = inputInt()
    
    if N == 1:
        print(1)
        sys.exit()
    
    ans = 0
    ansans = 0
    for i in range(1, N+1):
        tmp = 0
        han = i
        aaa = i
        while True:
            if han % 2 == 0:
                han = han / 2
                tmp += 1
            else:
                break
        if tmp > ans:
            ans = tmp
            ansans = aaa
            
    print(ansans)
    
if __name__ == "__main__":
	main()

Solution (Python):
li = [1,2,4,8,16,32,64]
n = int(input())
if n in li:
    print(n)
    exit()
    
li.append(n)
li.sort()
num = li.index(n)
print(li[num-1])

Solution (Python):
n = int(input())
ans = 2
if n != 1:
    while ans <= n:
        ans *= 2
    ans /= 2
    print(int(ans))
else:
    print(1)

Solution (Python):
N = int(input())
if N == 1:
    print(1)
elif N < 4:
    print(2)
elif N < 8:
    print(4)
elif N < 16:
    print(8)
elif N < 32:
    print(16)
elif N < 64:
    print(32)
else:
    print(64)

Solution (Python):
N = int(input())
mxc = -1
mxi = 0
for i in range(1,N+1):
    c = 0
    x = i
    while x%2 ==0:
        c +=1
        x = x//2
    if c > mxc:
        mxi = i
        mxc = c
print(mxi)

Solution (Python):
N = int(input())
a = 1

while a*2<=N:
  a*=2
  
print(a)

Solution (Python):
a = int(input())
if a<=1:
  print(1)
elif a<=3:
  print(2)
elif a<=7:
  print(4)
elif a<=15:
  print(8)
elif a<=31:
  print(16)
elif a<=63:
  print(32)
else:
  print(64)

Solution (Python):
n = int(input())
num = 1
while num <= n:
  num *= 2
print(num // 2)

Solution (Python):
N = int(input())

ans = 1
while ans <= N:
    ans *= 2

print(int(ans / 2))

Solution (Python):
N = int(input())
cut = 0
lis = [ a for a in range(1, N+1)]
while True:
  li_yojo = [ a % 2 for a in lis]
  if li_yojo.count(0) == 0:
    break
  else:
    lis = [ a / 2 for a in lis]
    cut += 1
        
print(2 ** (cut))

Solution (Python):

N = int(input())
ans = 0 
ans_count = 0
for i in range(1,N+1):
  count = 0
  tmp = i
  while tmp%2 == 0 :
    tmp = tmp/2
    count += 1
  if count >= ans_count:
    ans_count = count
    ans = i

print(ans)

Solution (Python):
n = int(input())
ans = 1
while True:
    if ans * 2 > n:
        break
    ans *= 2
print(ans)

Solution (Python):
n=int(input())
sp = 0
sp_i=1
for i in range(1,n+1):
  s_i=i
  count =0
  a =True
  while a:
    if i % 2 ==0:
      i=i/2
      count += 1
    else:
      a =False
  if count >sp:
    sp = count
    sp_i = s_i
    
    
print(sp_i)

Solution (Python):
n  = int(input())
count = [0] * (n + 1)
for i in range(1,n+1):
    k = i
    while 1:
        if i == 0:
            break
        elif float(i % 2) == 0.0:
            count[k] += 1
            i = int(i / 2)
        else:
            break
print(1) if n== 1 else print(count.index(max(count)))

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

Solution (Python):
N = int(input())

def hmtd(n):
  ans = 0
  while n % 2 == 0:
    n /= 2
    ans += 1
  return ans

div = []
for i in range(1,N+1):
  div.append(hmtd(i))
  
print(2**max(div))

Solution (Python):
N = int(input())
i = 1
while i <= N:
    i = i*2
    
print(int(i/2))

Solution (Python):
N = int(input())

ans = 0
while 2**ans <=N:
  ans += 1
print(2**(ans-1))

Solution (Python):
a = int(input())
b = 1
while True:
    if b <= a:
        b *= 2
    else:
        print(b // 2)
        break

Solution (Python):
a=int(input())
for i in  range(8):
    if 2**i>a:
        print(2**(i-1))
        break
    elif i==a:
        print(2**i)
        break

Solution (Python):
n = int(input())
ans = 0
for i in range(7):
  if 2 ** i <= n:
    ans = 2 ** i
print(ans)

Solution (Python):
N=int(input())
a=1
while a*2<=N:
  a*=2
print(a)

Solution (Python):
N=int(input())
if N==1:
  print(1)
elif 2<=N<4:
  print(2)
elif 4<=N<8:
  print(4)
elif 8<=N<16:
  print(8)
elif 16<=N<32:
  print(16)
elif 32<=N<64:
  print(32)
else:
  print(64)

Solution (Python):
print(2**(len(bin(int(input())))-3))

Solution (Python):
N = int(input())
counter =-1 
number = 0
for i in range(N):
    k = i+1
    now_counter = 0
    while(k % 2 == 0):
        now_counter += 1
        k /= 2
    if(now_counter > counter):
        number = i+1
        counter = now_counter
print(number)

Solution (Python):
print(2**(len(bin(int(input())))-3))

Solution (Python):
n =int(input())
arr=[]
for i in range(1,n+1):
  tmp = i
  cnt=0
  while tmp%2 == 0:
    tmp = tmp //2
    cnt+=1
  arr.append(cnt)
print(range(1,n+1)[arr.index(max(arr))])

Solution (Python):
import math
print(2**math.floor(math.log2(int(input()))))

Solution (Python):
N = int(input())
cur = 1
while 2*cur <= N:
    cur *= 2
print(cur)