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

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

x = 2
while x <= n:
	x *= 2

if n < 2:
	print (str(n))
else:
	print (str(int(x/2)))

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

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

count=1

while count <= s:
    count = count * 2

count = count / 2

print(int(count))

Solution (Python):


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

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

Solution (Python):
a=int(input())
b=1
while (b<<1)<=a:
    b=b<<1
print(b)

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

result = 0
while N / 2 >= 1.0:
    N /= 2
    result += 1
print(2**result)

Solution (Python):
N=int(input())
N|=N>>1
N|=N>>2
N|=N>>4
N|=N>>8
print((N+1)>>1)

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

Solution (Python):
N = int(raw_input())
data = [1, 2, 4, 8, 16, 32, 64]
print max([d for d in data if d <= N])

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

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

Solution (Python):

N = int(input())

base = 2
mul = 0
while True:
    mul += 1
    if base ** mul > N:
        break

print(base ** (mul - 1))

Solution (Python):
a = int(input())
temp = [0]*(a+1)
for i in range(a,0,-1):
    b = i
    while b%2 ==0:
        temp[i] += 1
        b = b//2
if temp.index(max(temp))==0:
    print(1)
else:print(temp.index(max(temp)))

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
gosa = 1.0 / 10**9
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


def main():
    N = I()
    r = 0
    while N>=2:
        N //= 2
        r += 1

    return 2**r



print(main())

Solution (Python):
def countdiv(n):
	m = n
	cnt = 0
	while m % 2 == 0:
		cnt += 1
		m = m / 2
	return cnt

n = int(raw_input())
max = 0
nmb = 1

for i in range(1, n+1):
	tmp = countdiv(i)
	if tmp > max:
		max = tmp
		nmb = i

print nmb

Solution (Python):
from sys import stdin
ma = -1
ans = -1
n = int(stdin.readline())
for i in xrange(1,n+1):
 x = i
 cn = 0
 while x%2==0:
  x/=2;cn+=1
 if cn > ma:
  ma = cn;ans = i
print ans

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


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

Solution (Python):
N = int(input())
score = 0
ans = 0
if N == 1:
    print(1)
else:
    for i in range(N,0,-1):
        s = i
        c=0
        while (i % 2 == 0) :
            i /= 2
            c += 1
        if score < c:
            score = c
            ans = s
        
    print(ans)

Solution (Python):


n=int(raw_input())
m=1
for i in xrange(7):
 x=2**m
 if n>=x:
  m+=1
print 2**(m-1)

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

print(2**(ans-1))

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

ans = -1
mc = -1
for i in range(1, N+1):
    x = i
    c = 0
    while x % 2 == 0:
        x /= 2
        c += 1
    if c > mc:
        ans = i
        mc = c
print ans

Solution (Python):

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

Solution (Python):
import numpy as np
N = int(input())
print(2**int(np.log2(N)))

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

C=0
L=[]

if N==1:
    print(1)

else:
    for i in range(8):
        C=2**i
        L.append(C)
        if C>N:
            print(L[-2]) 
            break

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

Solution (Python):
n=int(input())
t=[2,4,8,16,32,64]
c=0
if n==0:print("0")
elif n==1:print("1")
elif n>=64:print("64")
else:
    for i in t:
        if n < i:
            print(t[c-1])
            break
        c=c+1

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

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

Solution (Python):
import logging
logging.basicConfig(level=logging.CRITICAL,format=' %(asctime)s - %(levelname)s - %(message)s')

def power(n):
    i = 1
    logging.info('func start')
    while n > 0:
        i *= 2
        n -= 1
        logging.debug('i = {}, n = {}'.format(i,n))
    logging.info('func end')
    return i

i = 0
n = int(input())
logging.info('in loop')
while not (power(i + 1) > n):
    i = i + 1
    logging.debug('i = {}, pow(i) = {}'.format(i,power(i)))

logging.info('out loop')
print(power(i ))

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

A = [64,32,16,8,4,2]
if N<2:
    print(1)
else:
    for i in A:
        if N >= i:
            break
    print(i)

Solution (Python):
import sys
import math


def main():
    args = sys.stdin.readline().split()
    N = int(args[0])

    X = 0
    while True:
        X += 1
        temp = math.pow(2, X)
        if temp > N:
            temp = math.pow(2, X-1)
            break

    print(int(temp))

main()

Solution (Python):

def b():
    n = int(input())
    two_l = [ 2**x for x in range(7) ]
    res = 1
    for i in two_l:
        if i <= n:
            res = i
        else:
            break
    print(res)

b()

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

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

ans=1
while True:
    if n>ans: ans*=2
    elif n==ans: break
    else: ans/=2; break

print(int(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):
import math
import numpy as np
print(int(2**math.floor(np.log2(int(raw_input())))))

Solution (Python):
a = input()
if int(a) < int(2):
    print(a)
elif int(a) > int(1) and int(a) < int(4):
    print(2)

elif int(a) > int(3) and int(a) < int(8):
    print(4)

elif int(a) > int(7) and int(a) < int(16):
    print(8)

elif int(a) > int(15) and int(a) < int(32):
    print(16)

elif int(a) > int(31) and int(a) < int(64):
    print(32)

elif int(a) > int(63):
    print(64)

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

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

sig = [2,4,8,16,32,64,128]
sig.reverse()

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

for i in sig:
    if i <= N:
        print(i)
        exit()

Solution (Python):
a = int(input())
for i in range(a):
  if 2 ** i > a:
    break
  elif 2 ** i <= a:
    count = 2 ** i

print(count)

Solution (Python):


n = input()
m = 0
rank = 1
for i in range(1, n+1):
    j = i
    c = 0
    while True:
        if j % 2 == 0:
            j /= 2
            c += 1

        else:
            if m < c:
                m = c
                rank = i
            break

print rank

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

Solution (Python):
N = int(input())
s = 7
i = 0

for i in range(s):
    t = 64 >> i
    if (0 != (N & int(t))):
        print(t)
        break

Solution (Python):
maxNum = int(input())
favNum = 1
max2 = 0

for i in range(1,maxNum+1):
    currNum = i
    j = 0
    while(1):
        if currNum % 2 == 1:
            break
        else:
            currNum = currNum/2
            j += 1
    if max2 < j:
        max2 = j 
        favNum = i

print(favNum)

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

index = -1
for i in range(7):
    if 2 ** i <= N:
        index += 1
    else:
        pass

print(2 ** index)

Solution (Python):


N=int(input())

def waricount(num):
    kaeshi=0
    while num%2==0:
        kaeshi+=1
        num=num//2

    return kaeshi


ans=None
ans_val=-1
for idx in range(1,N+1,1):
    val=waricount(idx)
    if val > ans_val:
        ans=idx
        ans_val=val

print(ans)

Solution (Python):
import sys




def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


n = read_int()
res = 0
for i in range(100):
    r = 2 ** i
    if r <= n:
        res = r
    else:
        break
print(res)

Solution (Python):


N = int(input())

ma = -1
res = 1
for i in range(1, N+1):
    num = i
    tmp = num
    count = 0
    while num % 2 == 0:
        count += 1
        num = num / 2

    if count > ma:
        res = tmp
        ma = count

print(res)

Solution (Python):


N = input()

a=[]
i=1
while i<100:
	i=i*2
	if i>N:
		
		print i/2
		break

Solution (Python):
N=int(input())
x=1
while(x<=N):
    x*=2
if N==0:
    print(0)
else:
    print(x//2)

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

if N == 1:
    print("1")
else:
    l = [2**x for x in list(range(1, 8))]
    a = [ x for x in l if x <= N]
    print(max(a))

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

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

c_max = 0
i_max = 1
for i in range(1, N+1):
    c = 0
    num = i
    while True:
        if num % 2 != 0:
            break
        num = num // 2
        c += 1
    if c > c_max:
        c_max = c
        i_max = i
        
print(i_max)

Solution (Python):
f = len("{0:b}".format(int(input()))) - 1
a = '1' + '0' * f

print(int(a, 2))

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

Solution (Python):


n=input()
N=int(n)
a=0
ans=[]
for i in range(N):
    I=i+1
    a=0
    if I%2==0:
        a=a+1
        P=I/2
        for w in range(100):
            if P%2==0:
                a=a+1
                P=P/2
            else:
                ans.append(a)
                break
    else:
        ans.append(0)
max_idx = ans.index(max(ans))
print(max_idx+1)

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

Solution (Python):
Nmax = int(input())
ans = 1
maxnum = 0
for N in range(1, Nmax+1):
    cnt=0
    N_before = N
    while 1:
        if int(N/2) == int((N+1)/2):
            N = N/2
            cnt +=1
        else:
            break
    if cnt > maxnum:
        maxnum = cnt
        ans = N_before
print (ans)

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

Solution (Python):
max = int(input())
x = 1
while(True):
	if x > max:
		x = x/2
		break
	elif x == max:
		break
	else:
		x = x * 2

print(int(x))

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

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

Solution (Python):


import math
import sys

def main(argv):
    for line in sys.stdin:
        N = int(line)
        index = int(math.log(N, 2))
        print(int(math.pow(2, index)))

if __name__ == "__main__":
    main(sys.argv)

Solution (Python):
n = map(int, raw_input().split())[0]

i = 1

while i * 2 <= n:
    i *= 2

print i

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

if 1 <= N < 2:
	print(c[0])
elif 2 <= N < 4:
	print(c[1])
elif 4 <= N < 8:
	print(c[2])
elif 8 <= N < 16:
	print(c[3])
elif 16 <= N < 32:
	print(c[4])
elif 32 <= N < 64:
	print(c[5])
elif 64 <= N:
	print(c[6])

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

    if N == 1:
        print(1)
        return

    x = (64, 32, 16, 8, 4, 2)
    for i in x:
        if i <= N:
            print(i)
            break

main()

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

import math as m
print(2** m.floor(m.log(n, 2)))

Solution (Python):


N = int(input())

cnt = 0
while True:
    if N >= 2:
        N = N // 2
        cnt += 1
    else:
        break

print(2**cnt)

Solution (Python):
from math import log
print (max(1, 2**int(log(int(input()), 2))))

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

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

maxcount = -1
maxi = 0
for i in range(1, N+1):
  count = 0
  cur_i = i
  while True:
    if i % 2 == 0:
      i = i // 2
      count += 1
    else:
      break
  if count > maxcount:
    maxcount = count
    maxi = cur_i
print(maxi)

Solution (Python):
N = int(input())
cnt_max = 0
ans = 1
for n in range(1 , N+1):
    cnt = 0
    z = n
    while True:
        if z%2 == 0:
            cnt += 1
            z = z / 2
        else:
            break
    if cnt > cnt_max:
        cnt_max = cnt
        ans = n

print(ans)

Solution (Python):
a = int(input())
cnt = 0
while a:
    cnt += 1
    a >>= 1
print(1 << (cnt - 1))

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

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

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

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

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

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

res_list = []
tmp = 1
while True:
    if tmp > N:
        break
    res_list.append(tmp)
    tmp *= 2


print(max(res_list))

Solution (Python):

N = int(input())

num = 1

while (num<=N):
    num*=2
print(int(num/2))

Solution (Python):
import sys

N = int(input())						

i = 1
while (i*2) <= N:
	i *= 2

print(i)

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

print (int(a/2))

Solution (Python):


if __name__ == "__main__":
    n = int(input())
    r = 0
    while 2**r <= n:
        r += 1

    r -= 1

    print(2**r)

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

Solution (Python):
n=int(input())
l = [2,4,8,16,32,64]
if n==1:
    print(1)
else:
    while True:
        a=l.pop()
        if n>=a:
            print(a)
            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())
ans = 0
for i in range(8):
	if N >= 2**i:
		ans = 2**i
print(ans)

Solution (Python):


def main():
	n = int(input())
	powers = [2 ** i for i in range(7)]
	out = max([x for x in powers if x <= n])
	print(out)

if __name__ == '__main__':
	main()

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

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

print 2**(i-1)

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

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



import sys
import re
import math
import collections
import itertools
import functools

DEBUG = True
DEBUG = False

def dbg(*args):
    if DEBUG:
        print("DBG: ", file=sys.stderr, end="")
        print(*args, file=sys.stderr)



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

    k = math.floor(math.log(N, 2))
    print(2**k)

if __name__ == "__main__": main()

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):
num = int(input())
cnt =0
while num>1:
    num = int(num/2)
    cnt +=1
print(2**cnt)

Solution (Python):
N = int(raw_input())
n = 1
while n * 2 <= N:
  n *= 2
print n

Solution (Python):
n = int(input())
pow2 = [2 ** item for item in range(10)]
for item in pow2[::-1]:
    if(item <= n):
        print(item)
        break

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

i = 1
while(1):
    if i*2 > N:
        break
    i = i*2
print(i)

Solution (Python):
from math import log

ans = 1

for i in range(1,int(input())+1):
    if int(log(i,2)) > int(log(ans,2)):
        ans = i

print(ans)

Solution (Python):

n = int(input())

k = 0
while 1:
    if 2 ** k > n:
        break

    ans = 2 ** k
    k += 1

print(ans)