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):
n = int(input())
ans = [1, 2, 4, 8, 16, 32, 64]

print(max([i for i in ans if n-i >= 0]))

Solution (Python):


import itertools
from collections import Counter
from collections import defaultdict
import bisect

def main():
    N = int(input())
    ans = 0
    count = -1
    for i in range(1, N+1):
        c = 0
        v = i
        while v % 2 == 0:
            c += 1
            v //= 2
        if c > count:
            count = c
            ans = i

    print(ans)


if __name__ == '__main__':
    main()

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

ans = 1
for i in range(N+1):
    if ans*2 > N:
        break
    ans *= 2
print(ans)

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

Solution (Python):
N = int(input())
for i in range(N, 0, -1):
	a = bin(i)
	if a[2] == "1":
		if len(a) == 3:
			print(1)
			exit()
		elif not "1" in a[3:]:
			print(i)
			exit()

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

Solution (Python):
import math
N = int(input())
c = 0
while True:
  if N // 2 > 0:
    c += 1
    N = N // 2
  else:
    break
print(pow(2, c))

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

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

print(ans)

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

Solution (Python):
N = int(input())
ans = 1
cnt_ans = 0

for i in range(1,N+1):
    tmp = i
    cnt = 0
    while tmp % 2 == 0:
        tmp /= 2
        cnt += 1
    if cnt > cnt_ans:
        ans = i
        cnt_ans = cnt
    
print(ans)

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math


N = int(input())

ans = 1
cnt_ans = 0
for i in range(1,N+1):
    tmp = i
    cnt = 0
    while tmp % 2 == 0:
        tmp //= 2
        cnt += 1
    if cnt > cnt_ans:
        ans = i
        cnt_ans = cnt

print(ans)

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

ans, Max = 1, 0
for i in range(1, N+1):
    ct = 0
    tmp = i
    while tmp % 2 == 0:
        tmp //= 2
        ct += 1
    if ct > Max:
        Max = ct
        ans = i

print(ans)

Solution (Python):


x=int(input())

if x==1:
    print("1")
elif 2<=x<4:
    print("2")
elif 4<=x<8:
    print("4")
elif 8<=x<16:
    print("8")
elif 16<=x<32:
    print("16")
elif 32<=x<64:
    print("32")
elif 64<=x<=100:
    print("64")

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    

    
    
    
    
    
    

    
    

    
    
    
    
    
    
    
    
    
    INF = float("inf")

    
    MOD = 10**9+7
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    N = int(input().rstrip())
    cnt = 1
    ans = 1
    for i in range(1,N):        
        if(cnt*2 > N):
            ans = cnt
            break
        else:
            cnt *= 2
    print(ans)
    
if __name__ == '__main__':
    main()

Solution (Python):
def div(x):
    while x!=1:
        if x%2:
            return False
        x//=2
    return True
for i in range(int(input()),0,-1):
    if div(i):
        print(i)
        break

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(10):
    if 2**i <= n:
        r = i
    else:
        break
print(2**r)

Solution (Python):
N = int(input())
check = 0
ans = 1
for i in range(1, N+1):
    cnt = 0
    j = i
    while j%2 == 0:
        cnt += 1
        j //= 2
    if cnt > check:
        ans = i
        check = cnt

print(ans)

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

Solution (Python):
N = int(input())
p = 10
res = 0

for i in range(p):
  if 2** i <= N:
    res = i
  else:
    break
    
print(2**res)

Solution (Python):
import math

n = int(input())
print(2 ** math.floor(math.log2(n)))

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

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

Solution (Python):
n=int(input())
s=[2**p for p in range(7)]
print(max([c for c in s if c<=n]))

Solution (Python):
n=int(input())
s=[2**p for p in range(7)]
print(max([c for c in s if c<=n]))

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

score = {}
for i in range(1, n+1):
    c = 0
    i_ = i
    while(1):
        if i_ % 2 == 0:
            i_ /= 2
            c += 1
        else:
            break
    score[i] = c 

ans = max(score.items(), key=lambda x:x[1])[0]    
        
print(ans)

Solution (Python):
N=int(input())
P=0
for i in range(8) :
  if 2**i <= N : 
    P=2**i 
  else :
    break
print(P)

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

max_n = 0
max_times = -1
for i in range(1, N + 1):
    times = 0
    original_i = i
    while i % 2 == 0:
        i //= 2
        times += 1
    if times >= max_times:
        max_n = original_i
        max_times = times
print(max_n)

Solution (Python):

num = int(input())
max=0
for i in range(1,num+1):
  count=0
  work=i
  while work%2==0:
    work=work//2
    count = count+1

  if max<count:
    max=count
    ans=i
if(max==0):
  print(1)
else:
  print(ans)

Solution (Python):
N=int(input())
a=b=c=0
for i in range(N+1):
    if i!=0:
        j=i
        while i%2==0:
            a=a+1
            i=int(i/2)
        if a>b:
            b=a
            c=int(j)
        a=0
if c==0:
    print(1)
else:
    print(c)

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

def func(N):
	for i in range(7, 0, -1):
		if 2**i <= N:
			print(2 ** i)
			break
	else:
		print(N)





func(N)

Solution (Python):
n=int(input())
i=0
m=[]
while 2**i<=n:
  if 2**i<=n:
    m.append(2**i)
    i=i+1
print(m[-1])

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

Solution (Python):
n=int(input())
if n<2**1:
  print(1)
elif n<2**2:
  print(2)
elif n<2**3:
  print(4)
elif n<2**4:
  print(8)
elif n<2**5:
  print(16)
elif n<2**6:
  print(32)
elif n<2**7:
  print(64)

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

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

Solution (Python):
n = int(input())
two = 2
while n >= two:
	two = two*2
print(two//2)

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

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

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

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

Solution (Python):
N = int(input())
max_counter = 0
ans = 1

for i in range(N+1):
    counter = 0
    ans_i = i
    for j in range(7):
        if i % 2 == 0:
            counter += 1
            i = i / 2
        else:
            if counter > max_counter:
                 max_counter = counter
                 ans = ans_i
            break

print(ans)

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

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

Solution (Python):
nums = []
anss = []
for i in range(1, int(input())+1):
    count = 0
    while i%2 == 0:
        i //= 2
        count += 1
    anss.append(count)
print(anss.index(max(anss))+1)

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

Solution (Python):
n = int(input())
A = [2 ** i for i in range(1, 7)]
ans = 1
for a in A:
  if (n < a):
    break
  ans = a
print(ans)

Solution (Python):
n = int(input())
ans = [-1000] + [0] * n
for i in range(1, n + 1):
  j = i
  while (j % 2 == 0):
    ans[i] += 1
    j /= 2
print(ans.index(max(ans)))

Solution (Python):
import sys
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())

n = ni()

for i in range(n, -1, -1):
    if bin(i)[2:].count('1') == 1:
        print(i)
        exit()

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

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

Solution (Python):
def get(x):
    cnt = 0
    while x % 2 == 0:
        cnt += 1
        x = x/2
    return cnt
n = int(input())
at = 1
ans = 0
for i in range(1,n+1):
    a = get(i)
    if ans < a:
        ans = a
        at = i
print(at)

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

Solution (Python):
n = int(raw_input())
count0 = 0
ans = 1
for i in range(1, n+1):
	count = 0
	j = i
	while j % 2 == 0:
		j = j / 2
		count += 1
		if count > count0:
			ans = i
			count0 = count
print ans

Solution (Python):
a = int(input())
max_count = 0
max_number = 1

for i in range(1,a+1):
    count = 0
    hold = i
    while i%2 == 0:
        count += 1
        i //= 2
    if count > max_count:
        max_count = count
        max_number = hold
        
print(max_number)

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())
l=[i for i in range(1,n+1)]
lst=[]
for i in range(n):
  a=0
  p=l[i]
  q=p
  while q%2==0:
    a+=1
    q=q//2
  lst.append((a,p))
lst.sort(reverse=True)
print(lst[0][1])

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

S = [1, 2, 4, 8, 16, 32, 64]
ans = -1
for s in S:
    if s <= N:
        ans = s

print(ans)

Solution (Python):

n = int(input())

x = [2 ** i for i in range(7)]

import bisect

b = bisect.bisect_right(x, n)

print(x[b-1])

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

Solution (Python):

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

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

Solution (Python):
import sys

N = int(sys.stdin.readline())

if N in [1, 2, 4, 8, 16, 32, 64]:
    print(N)
else:
    sorted_list = sorted([1, 2, 4, 8, 16, 32, 64, N])[::-1]
    min_index = sorted_list[sorted_list.index(N) + 1]
    print(min_index)

Solution (Python):
m = int(input())
a = 1
for c in range(7):
  if (2 ** c) > m:
    break
  a = (2 ** c)
 
print(a)

Solution (Python):
n=int(input())
import math
ans=2**int(math.log(n,2))
print(ans)

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

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

max_num = 1
max_cnt = 0
for n in range(1, N+1):
    cnt = 0
    tmp_n = n
    while True:
        if tmp_n % 2 == 0:
            cnt += 1
            tmp_n /= 2
        else:
            if cnt > max_cnt:
                max_num = n
                max_cnt = cnt
            break

print(max_num)

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

mx = 0
for _ in range(N):
    num = 2**_
    if num <= N and mx < num:
        mx = num
print(mx)

Solution (Python):
n = int(input())
a = 1
while a <= n:
    a_ = a * 2
    if a_ > n:
        break
    else:
        a = a_
print(a)

Solution (Python):
N=int(input())
num = [1,2,4,8,16,32,64]
if N>=64:
  print(64)
else:
  for i in range(len(num)):
    if num[i]>N:
      print(num[i-1])
      break

Solution (Python):
N = int(input())
ans = 0
for i in range(N+1):
  a = i
  cnt = 0
  while a > 1:
    if a % 2 == 1:
      break
    else:
      a  = a//2
      cnt += 1
  ans = max(2**cnt,ans)

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())

max_count = 0
for i in range(1, N+1):
  n = i
  count = 0
  while n > 0 and n % 2 == 0:
    n = n//2
    count += 1
  if count == max(max_count, count):
    res = i
    max_count = count
print(res)

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

max_count = 0
for i in range(1, N + 1):
    n = i
    count = 0
    while n > 0 and n % 2 == 0:
        n = n // 2
        count += 1
    if count == max(max_count, count):
        res = i
        max_count = count

print(res)

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

tmp=0
for l in range(1,N+1):
    cnt=0
    while l%2==0:
        l/=2 
        cnt+=1

    
    tmp=max(cnt, tmp)
    ans=2**tmp

print(ans)

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

maximum = N
number = 0
for i in range(1,N+1):
  for j in range(1,N+1):
    if i%(2**j) != 0:
      break
  if j-1 > number:
    number = j-1
    maximum = i

print(maximum)

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    N = int(input())

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

    return ans


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

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

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

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

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

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

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

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

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

best = 1
best_count = 0
for n in range(1, N+1):
    i = n
    count = 0
    while True:
        q, mod = divmod(i, 2)
        if mod == 0:
            i = q
            count += 1
        else:
            break
    if count > best_count:
        best = n
        best_count = count

print(best)

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

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


n = int(input())
ans = 1
for i in range(1, n+1):
    if count_of_divide_2(ans) < count_of_divide_2(i):
        ans = i

print(ans)

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

while m <= n:
    m *= 2
print(m//2)

Solution (Python):
N = int(input())
ans = [2**i for i in range(0,7) if 2**i <= N]
print(ans[-1])

Solution (Python):
def break_number(N: int)->int:
    freq = [0] * (N+1)
    freq[0] = -float('inf')
    d = 2
    while d <= N:
        i = d
        while i <= N:
            freq[i] += 1
            i += d
        d <<= 1

    return freq.index(max(freq))


if __name__ == "__main__":
    N = int(input())
    ans = break_number(N)
    print(ans)

Solution (Python):
def break_number(N: int)->int:
    if N == 1:
        return 1

    freq = [0] * (N+1)
    d = 2
    while d <= N:
        i = d
        while i <= N:
            freq[i] += 1
            i += d
        d <<= 1

    return freq.index(max(freq))


if __name__ == "__main__":
    N = int(input())
    ans = break_number(N)
    print(ans)

Solution (Python):
N = int(input())
i=0
while 2**i<N:
  i += 1
  
if 2**i ==N:
  a =N
if 2**i>N:
  a =2**(i-1)

print(a)

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

while N >= a*2:
  a = a*2

print(a)

Solution (Python):
N = int(input())
ans = 0
escape = 0
for i in range(N, 0, -1):
	if i == 1:
		print(1)
		break
	ans = i
	while(1):
		if i%2 != 0:
			break
		if i%2 == 0 and i/2 != 1:
			i = i/2
		if i%2 == 0 and i/2 == 1:
			print(ans)
			escape = 1
			break
	if escape == 1:
		break

Solution (Python):
N = int(input())
max = 0
max_num = 1
for i in range(1,N+1):
    cnt = 0
    num = i
    while num % 2 == 0:  
        num /= 2
        cnt += 1
        if cnt > max:
            max = cnt
            max_num = i
print(max_num)

Solution (Python):
n=int(input())
cnt=1
X=[]
def two(n):
    cnt=0
    while n%2==0:
        n=n/2
        cnt+=1
    return cnt
res=0  
ans=n
for i in range(n,1,-1):
    if res<two(i):
        res=two(i)
        ans=i

print(ans)

Solution (Python):

N=int(input())
for i in range(0,7):
    ans =2**i
    if ans <= N and N< 2*ans:
        print(ans)
        break

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):
from math import log2,floor;print(2**floor(log2(int(input()))))

Solution (Python):
N = int(input())
max_count = 0
ans = 1
for i in range(1,N+1):
    count = 0
    num = i
    while(1):
        if(num%2 == 0):
            num = int(num/2)
            count += 1
        else:
            break
    if(count > max_count):
        max_count = count
        ans = i
print(ans)

Solution (Python):
N = int(input())
if N == 1:
    print(1)
    exit()
X = [2, 4, 8, 16, 32, 64, 128]
for i, x in enumerate(X):
    if N < x:
        print(X[i - 1])
        exit()

Solution (Python):
import math
N=int(input())
if N==1:
    ans=1
else:
    n1=math.log(N,2)
    n2=math.floor(n1)
    ans=2**n2
print(ans)

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)
elif 2>N>=1:
  print(1)

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

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

Solution (Python):
two=[1,2,4,8,16,32,64]
two.reverse()
n=int(input())
for i in range(7):
  if two[i]<=n:
    print(two[i])
    exit()

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

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

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

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

Solution (Python):
N = int(input())
list_2 = []
for i in range(7):
    list_2.append(2 ** i)
    
ans = 1
for i in list_2:
    if i <= N:
        ans = i
print(ans)

Solution (Python):
print(2**(len(bin(int(input()))[2:])-1))

Solution (Python):
n = int(input())
print(2**(len(bin(n)[2:])-1))

Solution (Python):
n = int(input())
M = 0
ans = 1
for i in range(1, n + 1):
  t = i
  s = 0
  while t % 2 == 0:
    t /= 2
    s += 1
  if M < s:
    M = s
    ans = i
print(ans)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007


def A():
    n = II()
    print("ABC"+str(n))
    return


def B():
    ni = [2 ** i for i in range(1, 10)]
    n = II()
    ans = 1
    for i in range(1, n + 1):
        if i in ni:
            ans = i
    print(ans)        
    return


def C():
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    B()

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007


"""
n = input()
print("ABC"+n)
"""


n = I()
p = [1]
for i in range(n):
    p.append(p[-1]*2)
    if p[-1] > n:
        print(p[-2])
        quit()

"""
def dijkstra():
    d[0] = 0
    q = [[0,0]]
    while q:
        dx, x = heappop(q)
        for y in v[x]:
            if d[y] > dx+1:
                d[y] = dx+1
                heappush(q,[d[y],y])
n,m = LI()
v = [[] for i in range(n)]
for i in range(m):
    a,b = LI()
    a -= 1
    b -= 1
    v[a].append(b)
    v[b].append(a)
d = [float("inf") for i in range(n)]
dijkstra()
if d[n-1] <= 2:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
"""


"""
k = I()
ans = [i+k//50 for i in range(50)]
k %= 50
for i in range(k):
    ans[i] += 51
    for j in range(50):
        ans[j] -= 1
print(50)
print(*ans)
"""

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

ma = 1

c = 0
while True:
	c += 1  
	k = 2**c
	if k > n:
		break      
    
	if k > ma:
		ma = k
		 
    
print(ma)

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

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

Solution (Python):

N = int(input())
a=0
for i in range(N):
    if 2**a<=N:
        a=a+1
    else: a=a
print(2**(a-1))

Solution (Python):
N = int(input())
l = list(range(1,N+1))
max = -99999999
for i in range(N):
       if (2**i) > max and 2**i <= N:
               max = 2**i
print(max)

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

for i in range(1,n+1):
    m=0
    while i%2==0:
        m+=1
        i=i/2
    else:
        l.append(m)

print(l.index(max(l))+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())
l = [1,2,4,8,16,32,64]
if N in l:
  print(N)
else:
  l = sorted(l+[N])
  print(l[l.index(N)-1])

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

Solution (Python):
n=int(input())
a=[1,2,4,8,16,32,64]
for i in range(n+1)[::-1]:
    if i in a:
        print(i)
        exit()

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

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

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

res = 1
for i in range(10):
    if 2**i > n:
        res = 2**(i-1)
        break

print(res)

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

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

print(ans)

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

while result*2 <= N:
    result *= 2

print(result)

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

tmp = 0
for i in range(2,N+1,2):
  cnt = 0
  while True:
    if(i%2 != 0):
      break
    cnt += 1
    i //= 2
  tmp = max(tmp, cnt)
print(2**tmp)

Solution (Python):

N = int(input())


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


print(ans)

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


if __name__ == "__main__":
    main()

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

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

n2 = 1
while True:
	if n < n2:
		break
	n2 *= 2
	
print(n2//2)

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

Solution (Python):
n = int(input())
num=0
if n==1:
    print(1)
    exit()
else:
    for i in range(1,n+1):
        k=0
        c=i
        while True:
            if c%2==0:
                c/=2
                k+=1
            else:
                break
        if k>num:
            num=k
            ans=i
print(ans)

Solution (Python):
from math import log2

import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline


def ceil(n):
    return int(-n//1)*(-1)


N = int(input())

ans = ceil(log2(N))
if 2**ans > N:
    ans -= 1
print(2**ans)

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

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

Solution (Python):
""" AtCoder """

N = int(input())
ans_list = [2, 4, 8, 16, 32, 64]
ans_list = ans_list[::-1]

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

for i in range(7):
    if N >= ans_list[i]:
        print(ans_list[i])
        break

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())
i = 0

while(1):
  if(pow(2,i)<= N <pow(2,i+1)):
    print(pow(2,i))
    break
  i += 1

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

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

Solution (Python):
N=int(input())
count=[0]*N
for i in range(1,N+1):
  SHOU=i
  while True:
    AMARI=SHOU%2
    SHOU=SHOU//2
    if AMARI==0:
      count[i-1]+=1
    else:
      break
print(1+count.index(max(count)))

Solution (Python):
N = int(input())
li = [2**i for i in range(0,7,1)]
flag = False
for i in range(N):
  for j in range(7):
    if li[j] == N:
      print(li[j])
      flag = True
      break
  if flag == True:
    break
  else:
    N -= 1

Solution (Python):

N = int(input())
for i in range(6, -1, -1):
  if N >= 2 ** i:
    print(2 ** i)
    break

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

i = 0

while True:
    if 2 ** i < N:
        i += 1
    elif 2 ** i == N:
        break
    else:
        i -= 1
        break

print(2 ** i)

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

nList = [i + 1 for i in range(N)]
res = -1
counter = -1
for n in nList :
    count = 0
    buf = n
    while buf % 2 == 0 :
        count += 1
        buf = buf / 2
    if counter < count :
        counter  = count
        res = n
print(res)

Solution (Python):
n = int(input())
count = 0
currCount = 0
ans = 0
for i in range(n+1):
    currCount = 0
    currNum = i
    while (i % 2) == 0:
        if i == 0:
            break
        i = int(i / 2)
        currCount += 1
    if count <= currCount:
        count = currCount
        ans = currNum
print(ans)

Solution (Python):
N = int(input())
j = 0
c2 = 0
for i in range(1, N+1):
	a = i
	c = 0
	while a % 2 == 0:
		c = c + 1
		a = a / 2
		if c >= c2:
			c2 = c
			j = i
if N == 1:
	print(1)
else:
	print(j)

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

a.sort(key=lambda x:x[1],reverse=True)
print(a[0][0])

Solution (Python):
n = int(input())
num = [2**i for i in range(10)]
while n not in num:
    n -= 1
print(n)

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

while n >= 2 ** power:
    power += 1

print(2**(power-1))

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

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

Solution (Python):
n = int(input())
cand = [2**x for x in range(7)]
for i in range(n,0,-1):
    if i in cand:
        print(i)
        break

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

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy

def j(q):
    if q==1: print("Heisei")
    else:print("TBD")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())


n = ip()                              











x = 1
while x<=n:
    x*=2
print(x//2)

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

while max*2 <= n:
    max *= 2

print(max)

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

Solution (Python):

"""
Created on Tue Feb 26 19:11:35 2019

@author: yuta
"""

def div(n):
    count = 0
    while n % 2 == 0:
        n /= 2
        count += 1
    return count

x = int(input())
y = list(range(1,(x + 1)))

mapped_list = list(map(div, y))
max_div = max(mapped_list)
print(y[mapped_list.index(max_div)])

Solution (Python):
N = input()

ans = 64
while True:
  if ans<=N:
    break
  ans /= 2
print ans

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

def f(n):
  if n == 1:
    return True
  elif n%2 == 0:
    return f(n/2)
  else:
    return False

n = int(input())
for i in range(n,0,-1):
  if f(i):
    print(i)
    break

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

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

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

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

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

Solution (Python):
N = int(input())
counter = []

for i in range(1, N + 1):
    m = i
    count = 0
    while m % 2 == 0:
        m //= 2
        count += 1
    counter.append(count)

print( counter.index(max(counter)) + 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())

for i in range(1,100):
  if 2**i > n:
    print(2**(i-1))
    exit()