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



Sample input:
7


Sample output:
4

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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))])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
res = 0
ans = 0
maxNum = -1
for i in range(1,n+1):
    cnt = i
    res = 0
    while True:
        if i % 2 != 0:
            break
        else:
            i //= 2
            res += 1
    if maxNum < res:
        maxNum = res
        ans = cnt
print(ans)

Submission status: Accepted

Solution code:
a = int(input())
b = 1
c = 0
while True:
    b *= 2
    c += 1
    if b > a:
        print(b // 2)
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

num = 1

while(N >= num*2):
    num *= 2

print(num)

Submission status: Accepted

Solution code:
n = int(input())

alist = [2 ** i  for i in range(1, 10) if 2 ** i <= 100]

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

for i in range(n, 0, -1):
    if  i in alist:
        print(i)
        break

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(0, 7):
    ans = i if N >> i & 1 else ans
print(1<<ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
m = (1, 0)
for i in range(1, n+1):
    j = 0
    ii = i
    while ii % 2 == 0:
        ii /= 2
        j += 1
    if m[1] < j:
        m = (i, j)
print(m[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

tp = 1
cnt = 0
while(tp <= n):
    tp *=2
    cnt+=1
    
print(pow(2,cnt-1))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#ABC68 B

n = int(input())
def count(n):
    c = 0
    while 1:
        if n % 2 == 0:
            n /= 2
            c += 1
        else:
            break
    return c

ma = 0
for i in range(1,n+1):
    if ma < count(i):
        ans = i
        ma = count(i)
if ma == 0:
    ans = 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=1
num=0
for i in range(1,n+1):
    check=i 
    c_num=0
    while check>0 and check%2==0:
        check//=2
        c_num+=1
    if num<c_num:
        num=c_num
        ans=i
print(ans)

Submission status: Accepted

Solution code:
s = int(input())
i = 0
while 2**i <= s:
  ans = 2**i
  i += 1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
ans = 1
for i in range(1, n + 1):
    c = 0
    rem = i
    while rem % 2 == 0:
        c += 1
        rem //= 2

    if c > cnt:
        cnt = c
        ans = i

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
nums = [0 for _ in range(N+1)]

for n in range(1, N+1):
    if n % 2 == 0:
        nums[n] = nums[n//2] + 1

ans = 0
max_nums = max(nums)
for n in range(1, N+1):
    if nums[n] == max_nums:
        print(n)
        break

Submission status: Accepted

Solution code:
n=int(input())
ans_max=0
ans_num=0
for i in range(n):
    num=i+1
    num_now=i+1
    #print(num)
    ans = 0
    while(num%2==0):
        num=num/2
        ans = ans+1
    if(ans>=ans_max):
        ans_max=ans
        ans_num=num_now
        #print('ansmax',ans_max)
        #print('ansmax',ans_num)

print(ans_num)

Submission status: Accepted

Solution code:
# ABC068-B
N = int(input())
if N == 1:
    print(N)
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)

Submission status: Accepted

Solution code:

N = int(input())

now = 1
while True:

    now *= 2

    if now > N:
        print(now//2)
        break

Submission status: Accepted

Solution code:
n=int(input())
ans=1
for i in range(n):
    ans*=2
    if ans>n:
        print(int(ans/2))
        break

Submission status: Accepted

Solution code:
n=int(input())
ans=0
ans_num=1
for i in range(1,n+1):
    count=0
    tmp=i
    while tmp%2==0:
        tmp//=2
        count+=1

    if ans<count:
        ans=count
        ans_num=i
print(ans_num)

Submission status: Accepted

Solution code:
n = int(input())
l = [1, 2, 4, 8, 16, 32, 64]
for i in l:
        if i > n:
                break
        else:
                num = i
print(num)

Submission status: Accepted

Solution code:
n=int(input())

if 2**0<=n<2**1:
    print(2**0)
elif 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)

Submission status: Accepted

Solution code:
N = int(input())
ans = 1
while N > 1:
    N //= 2
    ans *= 2

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
 
n_max = 1
cnt_max = 0
for i in range(1, n + 1):
  cnt = 0
  a = i
  while(a % 2 == 0):
    a /= 2
    cnt += 1
  if cnt > cnt_max:
    cnt_max = cnt
    n_max = i
 
print(n_max)

Submission status: Accepted

Solution code:
n=int(input())
o=0
def pi(a):
    ans=0
    while(a!=0):
        if a%2==1:
            i=0
            break
        a//=2
        ans+=1
    return ans
        
for i in range(1,n+1):
    u=pi(i)
    if u>=o:
        ans=i
        o=u
    u=0
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


main()

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    ans = 1
    c = 0
    for n in range(N, -1, -1):
        cc = 0
        nn = n
        while nn % 2 == 0 and n > 0:
            nn //= 2
            cc += 1
        if cc > c:
            ans = n
            c = cc
    print(ans)


main()

Submission status: Accepted

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

if n==x:
    print(x)
else:
    print(x//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=64
while a>n:
  a=a//2
print(a)

Submission status: Accepted

Solution code:
n=int(input())
ans=1
max=0
for i in range(1,n+1):
    ans=ans*2
    if ans>n:
        ans=int(ans/2)
        break
print(ans)

Submission status: Accepted

Solution code:
n=int(input())
ans=1
max=0
for i in range(1,n+1):
    cnt=0
    bin_str=bin(i)[2:]
    rev_bin=bin_str[::-1]
    
    for j in range(len(rev_bin)):
        if rev_bin[j]=="0":
            cnt+=1

    if cnt>max:
       max=cnt
       ans=i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
class Get_set_num:
	def __init__(self):
		self.num = int()
		 
	def set_num(self,num):
		self.num = num

	def get_num(self):
		return self.num

		 
do  = Get_set_num()
Inp = input()
Inp = int(Inp)


#割れる回数が最大の数とその回数を記録するリスト
#max[0]が対象となる数、max[1]が割れた回数
max_list = [1,0]

for i in range(Inp , 1 , -1):
	count=0
	do.set_num(i)
	while i % 2 == 0:
		count += 1
		i= i/2
		if count > max_list[1]:
			max_list.clear()
			max_list.extend([do.get_num(),count])
			
print(max_list[0])

Submission status: Accepted

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

for i in range(1, N + 1):
    if pow(2,i) > N:
        print(pow(2, i - 1))
        break

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
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)

Submission status: Accepted

Solution code:
# !/usr/bin python3
# -*- coding: UTF-8 -*-

n = int(input())

counter = 0
while 2 ** counter <= n:
    counter += 1

print(2 ** (counter - 1))

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    ans = 1
    ct = 0
    while True:
        ct += 1
        ans = 2 ** ct
        if ans > N:
            break

    print(2 ** (ct-1))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
res = -1
m = 0

if n == 1:
    print(1)
else:
    for i in range(1, n+1):
        a = i
        b = 0
        while a % 2 == 0:
            a = a // 2
            b += 1
        if b > m:
            m = b
            res = i
    print(res)

Submission status: Accepted

Solution code:
N = int(input())
while True:
    for i in range(7):
        b = 2**(6-i)
        if b <= N:
            break
    break
print(b)

Submission status: Accepted

Solution code:

from collections import defaultdict

def main():
    num = int(input())
    ans = 1

    while ans * 2 <= num:
        ans *= 2
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

N = n()
max_n = 0
max_count = -1

for i in range(1, N+1):
    count = 0
    c = i
    while c % 2 == 0:
        c //= 2
        count += 1
    if count > max_count:
        max_n = i
        max_count = count

print(max_n)

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
for i in range(0,8):
    if 2**i > N:
        break
    ans = 2**i
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

if n==0:
    print(0)
    exit(0)
cnt=0
while n>0:
    n = n>>1
    if n>0:
        cnt = cnt + 1

print(1<<cnt)

exit(0)

Submission status: Accepted

Solution code:
n = int(input())
if n == 1:
  print('1')
elif 1 < 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')

Submission status: Accepted

Solution code:
a = 0
ans = 0
N = int(input())
for i in range(1, N+1) :
  p = 0
  x = i
  while x % 2 == 0 :
    x //= 2
    p += 1
  if a <= p :
    a = p
    ans = i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
ans = 1
while ans <= N:
    ans <<= 1
ans >>= 1
print(ans)

Submission status: Accepted

Solution code:
n=int(input())

ans=1

while True:
    if ans*2>n:
        break

    else:
        ans=ans*2

print(ans)

Submission status: Accepted

Solution code:
n=int(input())

x=1

while True:
    if x*2>n:
        print(x)
        break
    else:
        x=x*2

Submission status: Accepted

Solution code:
def abc():
    n = int(input())
    ans = 1
    max_cnt = 0
    for i in reversed(range(1, n + 1)):
        cnt = 0
        tmp = i
        while True:
            if tmp % 2:
                break
            tmp //= 2
            cnt += 1
        if cnt > max_cnt:
            max_cnt = cnt
            ans = i
    print(ans)


abc()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
for i in range(9):
  a = 2**i
  if a <N:
    pass
    continue
  elif a >N:
    print(int(a/2))
    break

Submission status: Accepted

Solution code:
n=int(input());x=1
while 1:
    if x*2>n:
        print(x)
        break
    else:
        x=x*2

Submission status: Accepted

Solution code:
n = int(input())

flg = 0
cnt = 0
cnt_max = 0
tmp = 0
out = 1

for i in range(1,n+1):
    tmp = i
    flg = 0
    cnt = 0
    while(flg==0):
        #余りあり
        if tmp % 2 == 1:
            flg = 1
        else:
            tmp /= 2
            cnt += 1            
    if cnt > cnt_max:
        cnt_max = cnt
        out = i

print(out)

Submission status: Accepted

Solution code:
import sys

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

n = 1

while n <= N:
  n = n * 2

print(int(n/2))

Submission status: Accepted

Solution code:
# 整数の入力
numbers = int(input())
#　数に合わせてリストを作る
number_list = []
for num in range(numbers):
	number_list.append(num+1)

#引数が配列、何回処理できるか返す関数を作る 
def how_many_times_divisible(n):
	#回数をまずは０で定義
	count = 0
    #一つずつ処理される入ってきた値が割り切れなくなるまで
	while n % 2 == 0:
		#2でわる
		n = n / 2
		#回数を一上げる
		count = count + 1
    #割れなくなったら返す
	return count
  
#map(how_many_times_divisible,number_list))で最大何回割れるかをそれぞれ数えてリストにする
#print(list(map(how_many_times_divisible,number_list)))
#[0, 1, 0, 2, 0, 1, 0]
list_how_many_times_divisible = list(map(how_many_times_divisible,number_list))
#この中で一番大きい値の番号をだす
index_number = list_how_many_times_divisible.index(max(list_how_many_times_divisible))

#答えはインデックス番号と実際の値がずれるため+1をする
ans = index_number + 1
print(ans)

Submission status: Accepted

Solution code:
import bisect
import os
from collections import Counter, deque
from fractions import gcd
from functools import lru_cache
from functools import reduce
import functools
import heapq
import itertools
import math
import numpy as np
import re
import sys
import string

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")



N = int(sys.stdin.readline())
ans =1
while ans * 2 <=N:
    ans *= 2
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

maxcnt = 0
ans = 0
for i in range(1,n+1):
  cnt = 0
  for j in range(1,n):
    if i % 2**j == 0:
      cnt += 1
    else:
      if maxcnt < cnt:
        maxcnt = cnt
        ans = i
      else:
        break
if ans == 0:
  print(1)
else:
  print(ans)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

n = int(input())
for i in range(8):
    if n < 2**i:
        print(2**(i-1))
        sys.exit()

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
m = 0
if 0 <= n < 2 :
	print(n)
for i in range(1, 7) :
	if 2**i <= n < 2**(i+1) :
		print(2**i)

Submission status: Accepted

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


def solve(N: int):
    ret = 1
    while ret <= N:
        ret *= 2
    ret //= 2
    print(ret)
    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))  # type: int
    solve(N)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())

answer = 1
while answer*2 <= N:
  answer *= 2
  #print(answer)
print(answer)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
# 100以下の2で割りまくれる数を用意
A = [1,2,4,8,16,32,64]
n = int(input())
ans = 0
# nがAの配列内の数より↑ならその数を答えとして選択
for i in range(len(A)):
    if n >= A[i]:
        ans = A[i]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 2019/06/12
# AtCoder Beginner Contest 068 - B

# Input
n = int(input())

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

# Output
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

n = int(input())
ans = 1
wari = 0

for i, tmp in enumerate(range(1, n+1)):
    aa = 0
    while tmp % 2 == 0:
        tmp = tmp // 2
        aa += 1
    if wari < aa:
        wari = aa
        ans = i+1

print(ans)

Submission status: Accepted

Solution code:
x=1
X=int(input())

for i in range(7):
    if 2**i<=X:x=2**i
print(x)

Submission status: Accepted

Solution code:
N = int(input())

def main():
    tmp = curr = 1
    while True:
        tmp *= 2
        if N < tmp:
            break
        curr = tmp
    print(curr)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())

ans = 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def count(i):
    cnt = 0
    switch = 1
    while switch:
        if i % 2 == 1:
            return cnt
        else:
            cnt += 1
            i = i / 2

n = int(input())
correct_num = 1
split_cnt = 0
for i in range(n):
    m = count(i + 1)
    if m >= split_cnt:
        correct_num = i + 1
        split_cnt = m
print(correct_num)

Submission status: Accepted

Solution code:
N = int(input())
M = 0
num = 1
for i in range(1, N+1):
    count = 0
    while i % 2 ==0:
        i = i / 2
        count = count + 1
    if count > M:
        M = count
        num = i * (2 ** count)
print(int(num))

Submission status: Accepted

Solution code:
N = int(input())
ans = 1
while N >= 2:
    N = N // 2
    ans *= 2

print(ans)

Submission status: Accepted

Solution code:
n=int(input())
key=0
for i in range(1,7,1):
    if 2**i<=n:
        key=i
        
print(2**key)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
cnt = 0
ans = 1
for i in range(1,N+1):
    t = i
    c = 0
    while True:
        if t % 2 != 0:
            break
        t /= 2
        c += 1
    if c > cnt:
        ans = i
        cnt = c
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ma = 1
for i in range(1, N + 1):
    count = 0
    while i % 2 == 0:
        i //= 2
        count += 1
    ma = max(ma, 1 << count)
print(ma)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

max_div_cnt = 0
result = 1
for n in range(N):
  tmp = n + 1
  div_cnt = 0
  while tmp > 0:
    if tmp % 2 == 0:
      div_cnt += 1
      tmp //= 2
    else:
      break
  if div_cnt > max_div_cnt:
    max_div_cnt = div_cnt
    result = n + 1
print(result)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

s = [2**i for i in range(10)]

while 1:
  if N in s:
    print(N)
    exit()
  N-= 1

Submission status: Accepted

Solution code:
n = int(input())
import math
i = int(math.log2(n))
print(2**i)

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(N):
    if N >= 2**i:
        A = 2**i
print(A)

Submission status: Accepted

Solution code:
n = int(input())
count = 0
for i in range(1,n+1):
    count1 = 0
    while i % 2 == 0 and i >= 2:
        count1 += 1
        i = i//2
    count = max(count,count1)
print(2**count)

Submission status: Accepted

Solution code:
n=int(input())
ans=0
for i in range(1,n+1):
    if(i%2 == 1):
        continue
    else:
        c = 0
        while(i%2!=1):
            c+=1
            i=i//2
        if(ans < c):
            ans=c
print(2**ans)

Submission status: Accepted

Solution code:
N = int(input())
X = []
for i in range(N):
    n = 0
    a = 0
    n = N - i
    while  n % 2 == 0:
        n = n // 2
        a = a + 1
    else:
        X.insert(0, a)
print(X.index(max(X)) + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
A = int(0)
for i in range(N) :
    if N >= 2**i :
        A = 2**i

print(A)

Submission status: Accepted

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

Submission status: Accepted

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

while (c <= a):
	c = c * 2

print(int(c/2))

Submission status: Accepted

Solution code:
A=[1,2,4,8,16,32,64]
n=int(input())
a = 0
for i in range(len(A)):
    if n >= A[i]:
        a = A[i]
print(a)

Submission status: Accepted

Solution code:
a = int(input())
b = []
c = 1
while(c <= a):
     c = c*2
print(int(c/2))

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
n=int(input())
ans=[]
for i in range(7):
    if 2**i<=n:
        ans.append(2**i)

print(ans[-1])

Submission status: Accepted

Solution code:
intInp = int(input())
flag = True
maxValue = 1
tmp = 0
for i in range(1,intInp+1):
    # print("i is {}".format(i))
    tmpAns = i
    counter = 0
    while(True):
        if i % 2 == 0:
            # counter shows the number of division
            counter += 1
            # print("counter is {}".format(counter))
            i /= 2
        else:
            # if counter is lager than tmp, then the value i is more disivible than stored maxValue
            if(counter > tmp):
                # print("counter is {0}, tmp is {1}".format(counter,tmp))
                # print("i is {}".format(i))
                maxValue = tmpAns
                tmp = counter
            break
    # print("tmp is {}".format(tmp))
print(maxValue)

Submission status: Accepted

Solution code:
n=int(input())

if n<2:
  print(n)
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(int(i/2))

Submission status: Accepted

Solution code:
n=int(input())

k=0


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

Submission status: Accepted

Solution code:
N=int(input())

ans=1
max=0
cnt=0

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

Submission status: Accepted

Solution code:
n = int(input())

result = 1
max_c = 0
for i in range(1, n + 1):
    tmp = i
    count = 0
    while tmp > 0 and tmp % 2 == 0:
        tmp = int(tmp / 2)
        count += 1
    if max_c < count:
        max_c = count
        result = i

print(result)

Submission status: Accepted

Solution code:
import math
n = int(input())
curnum = 1
curmax = 0
for i in range(1, n + 1):
    c = int(math.log2(i))
    if c > curmax:
        curmax = c
        curnum = i
print(curnum)

Submission status: Accepted

Solution code:
# coding:utf-8
def recurcive(N,c):
    if N%2==0 and N!=0:
        c+=1
        return recurcive(int(N/2),c)
    else:
        return c
#print(recurcive(8,0))

N=int(input())
maxim=0

for i in range(1,N+1):
    if recurcive(i,0) > maxim:
        maxim=recurcive(i,0)
print(2**maxim)

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

res = -1
ans = -1
for i in range (1, N+1):
    count = 0
    a = i
    while a % 2 == 0:
        a /= 2
        count += 1
    
    if res < count:
        res = count
        ans = i

print(ans)

Submission status: Accepted

Solution code:
a = int(input())
l = list(range(1,a+1))
l1 = []
for i in l:
  count = 0
  while i % 2 == 0:
    i /= 2
    count += 1
  l1.append(count)
print(2**max(l1))

Submission status: Accepted

Solution code:
N = int(input())
count_list = []

for i in range(1,N+1):
    count = 0
    c = 1
    while c > 0:
        if i % 2 == 0:
            count += 1
            i /= 2
        else:
            c -= 1
    count_list.append(count)

print(2**max(count_list))

Submission status: Accepted

Solution code:
N = int(input())
list = []
for i in range(1, N + 1):
    counter = 0
    while i % 2 == 0:
        counter += 1
        i = i / 2
    list.append(counter)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
lis = [2,4,8,16,32,64]
ans = 1
for i in lis:
    if n >= i:
        ans = i
    else:
        break
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
i = 0

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

Submission status: Accepted

Solution code:
n = int(input())

tmp = 0
cnt = 0
ans = 1

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

print(ans)

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-

def solve():
    N = int(input())
    max_cnt = 0
    for i in range(N, 0, -1):
        cnt = 0
        num = i
        while True:
            if num == 1:
                print(i)
                return
            if num%2 == 0:
                num //=  2
                cnt += 1
                continue
            if cnt > max_cnt:
                max_cnt = cnt
                ans = i
            break
    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

N = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# 入力
N=int(input())

# 最大回数
c=0

# 最大回数時の整数（初期値は0回である1とする）
a=1

for x in range(1,N+1):
  _c=0
  _x=x
  while True:
    if _x%2==0:
      _x//=2
      _c+=1
    else:
      if c<_c:
        c=_c
        a=x
      break

# 出力
print(a)