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:
# -*- coding: utf-8 -*-

N = int(input())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
 
a = [2**i for i in range(7)]

print(max([x for x in a if x <= n]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


n=int(input())

def f(i):
  c=0
  while i>0:
    if i%2==0:
      c=c+1
      i=int(i/2)
    else:
      break
  return c

t=0
a=0
if n==1:
    print(1)
else:
    for i in range(n):
      fa=f(i+1)
      if t<fa:
        t=fa
        a=i+1

    print(a)

Submission status: Accepted

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


n = int(input().strip())
#----------
nums={}
for i in range(1,n+1):
    count=0
    tmp=i
    while (tmp % 2) == 0:
        if tmp % 2 == 0:
            tmp //= 2
            count += 1
    
    nums[i]=count

max_k = max(nums, key=nums.get)
print(max_k)

Submission status: Accepted

Solution code:
n=int(input())
for i in range(0,n+1):
    if 2**i<=n and 2**(i+1)>n:
        print(2**i)
        exit(0)
    else:
        pass

Submission status: Accepted

Solution code:
n = int(input())
ansc = 0
ans = 0
if n == 1:
    print(1)
    exit()
for i in range(1,n+1):
    x = i
    cnt = 0
    while x % 2 == 0:
        cnt += 1
        x /= 2
        if cnt > ansc:
            ansc = cnt
            ans = i
print(ans)

Submission status: Accepted

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

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

ans = 1

for i in range(10) :
    if 2**i <= N :
        ans = i

print(2 ** ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

i = 0
while True:
    if 2 ** i > n:
        break
    i += 1
print(2**(i-1))

Submission status: Accepted

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

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:
A = int(input())
i = 0
while (2 ** i) <= A:
    if 2 ** i == A:
        print(A)
        break
    elif (2 ** i) < A:
        i += 1
        continue
else: print(2 ** (i - 1))

Submission status: Accepted

Solution code:
n = int(input())

l = [2**i for i in range(8)]

if n==1:
  print(1)
  exit()
for i,v in enumerate(l):
  if n < v:
    print(l[i-1])
    exit()

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())
ans = 1
for i in range(10):
  if ans < n:
    ans *= 2
  elif ans > n:
    print(ans // 2)
    exit()
  else:
    print(ans)
    exit()

Submission status: Accepted

Solution code:
def breaknumbeer(n):

    ans = 1

    while ans <= n:
        ans *= 2

    return int(ans / 2)

def main():
    n = int(input())
    print(breaknumbeer(n))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = int(input())
M = -1
res = 0

for i in range(1, N+1):
    cnt = 0
    j = i
    
    while j%2 == 0:
        j //= 2
        cnt += 1
    
    if M < cnt:
        M = cnt
        res = i

print(res)

Submission status: Accepted

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

print(2**ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(int(r/2))

Submission status: Accepted

Solution code:
n = int(input())
max_num = n
cnt_max = 0
for i in range(n,0,-1):
  cnt = 0
  t = i
  while t > 0:
    if t % 2 == 0:
      t = t//2
      cnt += 1
    else:
      break
  if cnt > cnt_max:
    cnt_max = cnt
    max_num = i
print(max_num)

Submission status: Accepted

Solution code:
N=int(input())
count=0
pw2=[]
for i in range(8):
    pw2.append(pow(2,i))
for i in range(7):
    if (pw2[i]<=N)and(N<pw2[i+1]):
        print(pw2[i])

Submission status: Accepted

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

  
if 2**i==N:
  print(2**i)
else:
  print(2**(i-1))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
bn = str(bin(n))
bn = "1" + (bn[3:]).replace("1", "0")
print(int(bn, 2))

Submission status: Accepted

Solution code:
N = int(input())
cnt_max = 0
num_max = 1
for i in range(1,N+1):
  cnt = 0
  num = i
  while True:
    if i%2 == 0:
        i = i/2
        cnt += 1
    else:
      break
  if cnt_max < cnt:
    cnt_max = cnt
    num_max = num
print(int(num_max))

Submission status: Accepted

Solution code:
N=int(input())
ans = 0
d=0
def calc(n):
    a = 0
    while(1):
        if n==0:
            return a
        if n%2==0:
            a+=1
            n = n//2
        else:
            return a
for i in range(1,N+1):
    a = calc(i)
    ans = max(ans,a)
for i in range(1,N+1):
    b=calc(i)
    if b==ans:
        d = i
print(d)

Submission status: Accepted

Solution code:
try:   
    N = int(input())
    num = [i for i in range(N+1) if i%2==0]
    ans = 1
    __ = 0
    for i in num:
        _ = format(i, 'b')[::-1].find("1")
        if __ < _:
            ans = i
            __ = _
    print(ans)
except EOFError:
    pass

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())
max_num = 1
max_counter =0
for i in range(1, n+1):
    if not i%2 == 0:
        continue
    else:
        num = i
        counter = 0
        while num%2 == 0:
            num //= 2
            counter += 1
        if max_counter < counter:
            max_counter = counter
            max_num = i
print(max_num)

Submission status: Accepted

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

while True:
  if n<2**i:
    break
  else:
    i+=1
print(2**(i-1))

Submission status: Accepted

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

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

print(2**cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math


def main():
    N = int(input())
    print(2**int(math.log2(N)))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
N = int(input())

upper_num = 1
upper_count = 0
for i in range(1,N+1,1):
    count = 0
    a, b = divmod(i,2)
    while b == 0:
        count += 1
        a, b = divmod(a,2)
#         print("{}:{}".format(i,count))
    if count > upper_count:
        upper_count = count
        upper_num = i
print(upper_num)

Submission status: Accepted

Solution code:
n = int(input())

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

print(i // 2)

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

Submission status: Accepted

Solution code:
N = int(input())

result = 128
while result > N:
    result //= 2
print(result)

Submission status: Accepted

Solution code:
N = int(input())
a = [N-2**i for i in range(0,7) if N-2**i >= 0]
print(2**a.index(min(a)))

Submission status: Accepted

Solution code:
N = int(input())
a = [N-2**i for i in range(0,7) if N-2**i >= 0]
min_index = a.index(min(a))
print(2**min_index)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

count = [0 for __ in range(N)]
Nl = [i for i in range(1,N+1)]

for i,n in enumerate(Nl):
    while n%2==0:
        n /= 2
        count[i] += 1
idx = count.index(max(count))
print(Nl[idx])

Submission status: Accepted

Solution code:
def devide(dev):
	count = 0
	while dev % 2 == 0:
		dev /= 2
		count += 1
	return count

n = int(input())
count_cal = []

for i in range(1, n+1):
	count_cal.append(devide(i))

MAX = count_cal[0]

for k in range(len(count_cal)):
	if MAX <= count_cal[k]:
		MAX = count_cal[k]
		ans = k

print(ans + 1)

Submission status: Accepted

Solution code:
n=int(input())
for i in range(7,-1,-1):
    if n >= 2**i:
        k = i
        break
    else:
        pass
print(2**k)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(n):
    num = 2
    while num <= n:
        num *= 2
    return num // 2

_n = int(input())
print(solve(_n))

Submission status: Accepted

Solution code:
N = int(input())

counter = [0 for __ in range(N)]
Nl = [i for i in range(1,N+1)]

for i,n in enumerate(Nl):
    while n%2==0:
        n /= 2
        counter[i] += 1
idx = counter.index(max(counter))
print(Nl[idx])

Submission status: Accepted

Solution code:
n=int(input())

ans = 1
tmp_max = 0

for i in range(1,n+1):
    # iを何回2で割れるか？
    flag = True
    tmp_cnt = 0
    tmp_i = i
    while(flag):
        if tmp_i%2==0:
            tmp_cnt += 1
            tmp_i=int(tmp_i/2)
        else:
            flag = False
    if tmp_cnt >= tmp_max:
        tmp_max = tmp_cnt
        ans = i
        
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
max_cnt = 0
res = 1
for i in range(n,0,-1):
    cnt = 0
    nn = i
    while nn % 2 == 0:
        nn = nn / 2
        cnt += 1
    if cnt > max_cnt:
        max_cnt = cnt
        res = i
print(res)

Submission status: Accepted

Solution code:
n=int(input())
from numpy import log
print(pow(2,int(log(n)/log(2))))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = int(input())
len_a = len(str(bin(int(a))))-3
print(int("1" + "0"*len_a,2))

Submission status: Accepted

Solution code:
n = int(input())
# a,b = map(int, input().split())
# A = list(map(int, input().split()))
# AA = list(map(int, input().split()) for i in range(n))

res=0

for i in range(n+1):  
    if max(n,2**i)<=n:
        res=2**i
print(res)

Submission status: Accepted

Solution code:
# Problem https://atcoder.jp/contests/abc068/tasks/abc068_b
# python 3rd Try


import sys


def twoDividedCounter(N):
    answer = 0
    copyNumber = N
    while True:
        if copyNumber % 2 == 0:
            answer = answer + 1
            copyNumber = copyNumber / 2
        else:
            break
    return answer


def solver(N):
    answer = 1
    counter = 0
    for j in range(1, N+1):
        jcount = twoDividedCounter(j)
        if counter < jcount:
            answer = j
            counter = jcount

    return answer


if __name__ == "__main__":
    N = sys.stdin.readline().rsplit()
    print(solver(int(N[0])))

Submission status: Accepted

Solution code:
import math
n = int(input())
a = math.floor(math.log2(n))

print(2**a)

Submission status: Accepted

Solution code:
N = int(input())

c = []
for n in range(1, N+1):
    _n = n
    i = 0
    while True:
        a = _n % 2
        _n = _n // 2
        if a:
            c += [i]
            break
        i += 1

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

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 29, Jan, 2020
"""

import sys
import itertools

# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(readline())

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

print(ans//2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
king=int(0)
ans=int(1)
for i in range(1,n+1):
    a=i
    count=int(0)
    while a:
        if a%2==0:
            a/=2
            count+=1
        
        else:
            break

    if king<count:
        king=count
        ans=i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
suuji = int(input())
srclist = [1, 2, 4, 8, 16, 32, 64, 128]
dst = 0
for i in range(len(srclist)):
    if srclist[i] > suuji:
        break
print(srclist[i-1])
cntmax = 0
dst = 1
for i in range(suuji):
    for cnt in range(1, 1000):
        bit = 2**cnt-1
        if i & bit != 0:
            break
    if cntmax < cnt - 1:
        cntmax = cnt - 1
        dst = i

Submission status: Accepted

Solution code:
suuji = int(input())
srclist = [1, 2, 4, 8, 16, 32, 64, 128]
dst = 0
for i in range(len(srclist)):
    if srclist[i] > suuji:
        break
print(srclist[i-1])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
n = int(input())
i = 0
while True:
    if 2 ** (i+1) <= n: i+=1
    else: break
print(2**i)

Submission status: Accepted

Solution code:
n = int(input())
ans = [2**i for i in range(0, 8)]
ra = list(reversed(ans))

for i in range(len(ra)):
    if(ra[i] > n and ra[i+1] <= n):
        print(ra[i+1])

Submission status: Accepted

Solution code:
N = int(input())


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


ans = [two(i + 1) for i in range(N)]
print(ans.index(max(ans)) + 1)

Submission status: Accepted

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    ct=0
    while n!=0:
        ct+=1
        n=n//2
    print(2**(ct-1))
if __name__ == '__main__':
    do()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

N = int(input())

ans = 2 ** int(math.log2(N))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Problem https://atcoder.jp/contests/abc068/tasks/abc068_b
# Python 2nd Try


def solver(givenNumber):
    answer = 1
    counter = 0
    modCounter = [0] * givenNumber
    for j in range(0, givenNumber):
        eachCounter = 0
        baseNumber = j + 1
        while True:
            if baseNumber % 2 == 0:
                eachCounter = eachCounter + 1
                baseNumber = baseNumber / 2
            else:
                break
        modCounter[j] = eachCounter
    for j in range(0, givenNumber):
        if counter <= modCounter[j]:
            counter = modCounter[j]
            answer = j+1
    return answer


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
max2 = 0
maxi = 1
for i in range(1, n+1):
  m = 0
  k = i
  while k % 2 == 0:
    m += 1
    k = k / 2
  if max2 < m:
    max2 = m
    maxi = i
print(maxi)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
N = int(input())
ans = 1
while ans < N:
    if ans*2 <= N:
        ans *= 2
    else:
        break
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
flag = True
i = 1
while flag:
    if 2**i<=N:
        i+=1
    else:
        print(2**(i-1))
        flag = False

Submission status: Accepted

Solution code:
n = int(input())

ans_max = 0
for i in range(1,n+1):
    m = i
    a = 0
    while m % 2 == 0:
        m = m / 2
        a += 1
    if ans_max <= a:
        ans_max = a
        ans = i
print(ans)

Submission status: Accepted

Solution code:
#codng utf-8
N=int(input())
for i in range(7):
    if N>=2**i:
        ans=2**i
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
N=int(input())
ans=0

for i in range(N):
    num=i+1
    cnt=0
    
    while num%2==0:
        cnt+=1
        num=num//2
    ans=max(ans,cnt)

print(2**(ans))

Submission status: Accepted

Solution code:
N = int(input())

res = []
for i in range(1,N+1):
    counter = 0
    if i % 2 == 0:
        while i % 2 == 0:
            counter += 1
            i /= 2

        res.append(counter)
    else:
        res.append(counter)


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

Submission status: Accepted

Solution code:
ans = []
n = int(input())
m = [1,2,4,8,16,32,64]

for i in m:
	if i <= n:
		ans.append(i)

print(max(ans))

Submission status: Accepted

Solution code:
n=int(input())
a=1
while a<<1 <= n:
  a<<=1
print(a)

Submission status: Accepted

Solution code:
def main(n):
    b = [2**i for i in range(0, 7)]

    for i in range(n, 0, -1):
        if i in b:
            print(i)
            return


if __name__ == "__main__":
    n = int(input())

    main(n)

Submission status: Accepted

Solution code:
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N
import math

def intinput():
    return int(input())

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

def splitintinput():
    return map(int,input().split())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
a=0
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(1,N+1):
  if 2**i <= N:
    pass
  else:
    print(2**(i-1))
    break

Submission status: Accepted

Solution code:
N = int(input())
print(1<<len(bin(N))-3)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# Problem https://atcoder.jp/contests/abc068/tasks/abc068_b
# Python 1st Try


def solver(givenNum):

    answer = 1
    counter = 0
    rangeNum = range(0, givenNum)
    eachCount = [0] * givenNum
    for j in rangeNum:
        oneCount = 0
        nowNumber = j + 1
        while True:
            if nowNumber % 2 == 0:
                oneCount = oneCount + 1
                nowNumber = nowNumber / 2
            else:
                break
        eachCount[j] = oneCount
#    print(eachCount)
    for j in rangeNum:
        if counter <= eachCount[j]:
            counter = eachCount[j]
            answer = j + 1
    return answer


if __name__ == "__main__":
    print(solver(int(input())))

Submission status: Accepted

Solution code:
#coding:utf-8
n = int(input())
two = [1, 2, 4, 8, 16, 32, 64]
ans = 0

for i in range(7):
    if  two[i] <= n:
        ans = two[i]

print(ans)

Submission status: Accepted

Solution code:
a=int(input())
print(2**(len(bin(a))-3))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def divisible(n):
 ans = 0
 while n%2 == 0:
  n /= 2
  ans += 1
 return ans
 
N = int(input())
 
b = 0

c = 1
 
for i in range(1,N+1):
    if(divisible(i) > b):
      b = divisible(i)
      c = i
    
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

while True:
  if n >= t:
    t *= 2
  else:
    print(t // 2)
    exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
counta = 0
ans = 1
def hantei(i) :
    count = 0
    while True :
        if i % 2 == 0 :
            count+=1
            i = i // 2
        else :
            break
    return count
for i in range(1,N+1) :
    k = hantei(i)
    if k > counta :
        ans = i
        counta = k
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
num = int(input())
m = 1
for i in range(num):
    if num >= 2**i:
        m = pow(2,i)
print(m)

Submission status: Accepted

Solution code:
n = int(input())

resultMax = 0
resultI = 0
for i in range(n,0,-1) :
  result = 0
  t = i
  while t%2 == 0:
    t = t//2
    if t == 1 and result+1 >= resultMax:
      print(i)
      exit(0) 
    result += 1
  if resultMax <= result:
    resultMax = result
    resultI = i

print(resultI)

Submission status: Accepted

Solution code:
n = int(input())
L = []
j = 0
for i in range(n):
    s = list(bin(i+1)[2:])[::-1]
    cnt = 0
    while j <=n-1:
        if s[j] == "0":
            cnt +=1
            j +=1
            #print(j,cnt)
        elif s[j] == "1":
            L.append((cnt,i+1))
            cnt=0
            break
    j =0
print(max(L)[1])

Submission status: Accepted

Solution code:
N=int(input())
for i in range(7):
  x=2**i
  if x<=N:
      max=2**i
print(max)

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
N = int(input())

# 2で割れる最大数は2**x. 2**x がNを超えるかどうかで判定する
for x in range(10):
    if N < 2**x:
        break

print(2**(x-1))

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
ans=[]
l=[]
for i in range(1,N+1):
    l=list(str(format(i,'b')))
    l.reverse()
    l_=l.index('1')
    ans.append([l_,i])
ans.sort(reverse=True)
print(ans[0][1])

Submission status: Accepted

Solution code:
N = int(input())

ans = 1
while True:
  ans *=2
  if ans> N:
    print(int(ans /2))
    break

Submission status: Accepted

Solution code:
n = int(input())
target  = [2**i for i in range(1,7)]
for i in reversed(target):
  if n >= i :
    print(i)
    exit()
print(1)

Submission status: Accepted

Solution code:

n=int(input())
cntm=0
ans=1
for i in range(1,n+1):
    a=i
    cnt=0
    while a%2==0:
        a//=2
        cnt+=1
    if cntm<cnt:
        ans=i
        cntm=cnt
print(ans)

Submission status: Accepted

Solution code:
# ABC068 B "Break Number"
N = int(input())
for i in range(7,-1,-1):
  if N >= 2**i:
    print(2**i)
    break

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 068 - B
# -*- encoding: UTF-8 -*-

n = int(input())

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

num = num -1
result = int(2 ** num)

print(result)

Submission status: Accepted

Solution code:
n=int(input())
a=0
if n<=2:
    print(n)
elif n<4:
    print(2)
else:
    for i in range(n//2):
        if 2**a<=n:
            a+=1
        else:
            break
    print(2**(a-1))

Submission status: Accepted

Solution code:


import numpy as np


n=int(input())
ans=1
while(1):
    n=n>>1
    if(n==0):
        print(ans)
        exit(0)
    ans*=2

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

l = [2 ** x for x in range(0, 10)]

for i in range(0, 9):
    if l[i] <= n < l[i + 1]:
        print(l[i])
        break

Submission status: Accepted

Solution code:
N = int(input())

# 1から始まるNまでの連続数を生成して配列に入れる
L = []
for i in range(N):
    L.append(i + 1)

cntArray = []
maxNum = 0
i_when_max = 0
for i in range(len(L)):
    cnt = 0
    while L[i] % 2 == 0:
        cnt += 1
        L[i] = L[i] / 2
    cntArray.append(cnt)
    if cntArray[i] > maxNum:
        maxNum = cntArray[i]
        i_when_max = i

L = []
for i in range(N):
    L.append(i + 1)
print(L[i_when_max])

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
def How_many_times_devide(n):
    count = 0
    while n %2 == 0:
        n/= 2
        count += 1

    return count

N = int(input())
num_max = 1
count_max = 0
for i in range(1,N+1):
    count = How_many_times_devide(i)
    if count_max < count:
        count_max = count
        num_max = i

print(num_max)

Submission status: Accepted

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

N = int(input())
ans = [0, -1]
for i in range(1, N + 1):
    cnt = 0
    j = i
    while i % 2 == 0:
        cnt += 1
        i //= 2
    if cnt > ans[1]:
        ans = [j, cnt]
print(ans[0])

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
print(2**int(log2(N)))

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
#N = 100
i = 0
ans = 1
while True:
    i += 1
    p = pow(2, i)
    if p <= N:
        # print(p)
        ans = p
        pass
    else:
        # print('break {}'.format(p))
        break

print(ans)

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())
ans = 1
for i in range(7):
    if 2**i <= n:
        ans = 2**i
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
a = []
b = []
for i in range(1, n+1):
    x = 0
    b.append(i)
    while i % 2 == 0:
        x += 1
        i /= 2
    a.append(x)
y = a.index(max(a))
print(b[y])

Submission status: Accepted

Solution code:
n = int(input())

ans = 1

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

Submission status: Accepted

Solution code:
import math
n=int(input())
sisu=math.log(n,2)//1
print(int(2**sisu))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

N = int(input())

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

if N < a:
    a /= 2

print(int(a))

Submission status: Accepted

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

n = int(input())

"""
def n2count(n):
    if n%2==1:
        return 0
    else:
        return 1 + n2count(n//2)
        
lis = []
for i in range(1, 101):
    lis.append(n2count(i))
print(lis)
print(len(lis))
"""

lis_c = [0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 6, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 4, 0, 1, 0, 2, 0, 1, 0, 3, 0, 1, 0, 2, 0, 1, 0, 5, 0, 1, 0, 2]

m = max(lis_c[:n])
for idx, num in enumerate(lis_c[:n]):
    if num == m:
        print(idx+1)