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())
k = 0
count = 0
m = 0
for i in range(1, n + 1):
  count = 0
  j = i
  while j % 2 == 0:
    count += 1
    j = j // 2
  if i == 1:
    k = count
    m = i
  elif k < count:
    k = count
    m = i
print(m)

Submission status: Accepted

Solution code:
N = int(input())
r = 0
for i in range(1, N+1):
    for n, v in enumerate((2, 4, 8, 16, 32, 64)):
        if i % v == 0:
            r = max(r, n+1)
print(2**r)

Submission status: Accepted

Solution code:
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)
else:
    print(64)

Submission status: Accepted

Solution code:
n = int(input())
ans = 2

while ans <= n:
    ans = ans << 1

print(ans>>1)

Submission status: Accepted

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

Submission status: Accepted

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

while ans <= n:
    ans *= 2

print(int(ans / 2))

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

while a > 0:
  a = int(a / 2)
  b += 1
  
print(2**(b-1))

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

i = 1
while True:
    if N < i * 2:
        break

    i *= 2

print(i)

Submission status: Accepted

Solution code:
N = int(input())
x=0
array=[]
for i in range(N):
    n=i+1
    c=0
    while n%2==0:
        c+=1
        n/=2
    if x<=c:
        array.append(i+1)
        x=c
print(array[-1])

Submission status: Accepted

Solution code:
n = int(input())
count = 0

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

Submission status: Accepted

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

maxcount = 0
for i in range(N):
    if maxcount <= List[i]:
        maxcount = List[i]
        ans = i+1
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
print(2 ** (n.bit_length() - 1))

Submission status: Accepted

Solution code:
N = int(input())
l = list(range(1,N+1))
l_count = []
for e in l:
  count = 0
  while e % 2 == 0:
    e /= 2
    count += 1
  l_count.append(count)
max_index = l_count.index(max(l_count))
print(l[max_index])

Submission status: Accepted

Solution code:
# coding: utf-8

N = int(input())

l = [i for i in range(1, N + 1)]

max_count = 0
max_number = l[0] 
for number in l:
    n = number
    count = 0
    while (n % 2 == 0):
        n /= 2
        count += 1
    if count > max_count:
        max_count = count
        max_number = number

print(max_number)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def f(x, cnt):
    if x % 2 != 0 or x == 0:
        return cnt
    else:
        cnt += 1
        return f(x//2, cnt)

N = int(input())
ans, cnt = 0, 0
for i in range(1, N+1):
    c = f(i, 0)
    if c >= cnt:
        ans, cnt = i, c
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
n=int(input())
i=1
while 2**i <=n:
  i=i+1
i=i-1
print(2**i)

Submission status: Accepted

Solution code:
n = int(input())

dp = [0]*(n+1)

for i in range(n+1):
    t = i
    while t > 1:
        if(t%2 == 0):
            t = int(t/2)
            dp[i] += 1
        else:
            break

print(dp.index(max(dp))) if max(dp) != 0 else print('1')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin


def main() -> int:
    n = next_int()
    for i in range(n, 0, -1):
        if judge(i):
            print(i)
            break
    return 0


def judge(n: int) -> bool:
    while n % 2 == 0 and n != 0:
        n //= 2
    if n == 1:
        return True
    return False


def next_int() -> int:
    return int(next_str())


def next_str() -> str:
    result = ""
    while True:
        tmp = stdin.read(1)
        if tmp.strip() != "":
            result += tmp
        elif tmp != '\r':
            break
    return result


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n = int(input())
a = [1,2,4,8,16,32,64]
b = []
for i in a:
  if i <= n:
    b.append(i)
print(b[-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
ans = 0
for i in range(6+1): # 2**6 = 64
    if 2**i <= N:
        ans = 2**i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

res = 1
while True:
    if res * 2 <= N:
        res *= 2
    else:
        break
print(res)

Submission status: Accepted

Solution code:
n=int(input())
array=[]
for i in range (1,n+1):
    j=i
    count=0
    while(j%2==0):
        j=j/2
        count+=1
    array.append(count)
max=array[0]
for i in  range(n):
    if array[i]>=max:
        max=array[i]
        j=i
print(j+1)

Submission status: Accepted

Solution code:
import math
N = int(input())
n = int(math.log2(N))
ans = pow(2,n)
print(ans)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
count = 0
best = 0

for i in range(n, 0, -1):
    count = 0
    x = i
    while True:
        if x % 2 == 0:
            count += 1
            x = x / 2
        else:
            break
    if count > best:
        best = count
        ans = i
        
if ans == 0:
    ans = 1

print(ans)

Submission status: Accepted

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

n = int(input())

n_two_count = [two_count(n_i) for n_i in range(1, n+1)]
print(n_two_count.index(max(n_two_count))+1)

Submission status: Accepted

Solution code:
N = int(input())
ans = 1
bai2 = [2**i for i in range(0, 7)]

for i in bai2:
    if i<=N:
        ans = i
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
num = 0
ans = 1
for i in range(2, N + 1, 2):
    k = i
    rec = 0
    while k > 0:
        k //= 2
        rec += 1
    if rec > num:
        num = rec
        ans = i

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ct = 0
max_ct = 0
now = 0
max_num = 1
for i in range(1, n+1):
    now = i
    while (i % 2 == 0):
        i = i / 2
        ct += 1
    if max_ct < ct:
        max_ct = ct
        max_num = now
    ct = 0

print(max_num)

Submission status: Accepted

Solution code:
import math

N = int(input())

M = math.floor(math.log2(N))

print(2**M)

Submission status: Accepted

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

print(2**(count - 1))

Submission status: Accepted

Solution code:
n = int(input())

sisuu = 0
while True:
	if 2 ** (sisuu + 1) > n :
		break
	sisuu += 1

print(2 ** sisuu)

Submission status: Accepted

Solution code:
n = int(input())

index =0
while True:
    if 2**index > n:
        break
    index+=1

print(2**(index-1))

Submission status: Accepted

Solution code:
l = bin(int(input()))
s = len(l)-3
print(pow(2, s))

Submission status: Accepted

Solution code:
num=int(input())
max=0
maxnum=1
for ii in range(num):
    i=ii+1
    div=0
    while True:
        if i%2==0:
            i//=2
            div+=1
        else:
            break
    if(div>max):
        max=div
        maxnum=ii+1
print(maxnum)

Submission status: Accepted

Solution code:
n = int(input())

c = []

for i in range(n):
    now = 0
    for j in range(i + 1):
        now = 0
        k = j + 1
        while k % 2 == 0:
            now += 1
            k -= k // 2
            
    c.append(now)


#print(c)


print(max(range(len(c)), key = lambda i: c[i]) + 1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
list_2 = []
for i in range(0, 8):
    list_2.append(2 ** i)
count = 0
while True:
    if n >= list_2[count]:
        count += 1
        continue
    else:
        print(list_2[count-1])
        break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(num * 2 ** ans)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()

ans = 1
temp = 0
res = 0
for i in range(1,n+1):
    m = i
    temp = 0
    while m % 2 == 0:
        m //= 2
        temp += 1

    if temp > res:
        res = temp
        ans = i
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
N=int(input())
A=[1,2,4,8,16,32,64,101]
a=bisect.bisect_left(A,N)
print(A[a if A[a]==N else a-1])

Submission status: Accepted

Solution code:
import bisect
N=int(input())
A=[1,2,4,8,16,32,64,101]
a = bisect.bisect_left(A,N)
print(A[a if A[a]==N else a-1])

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

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

Submission status: Accepted

Solution code:
N = int(input())
flag = False
for i in range(N):
  if(2**i <= N < 2**(i+1)):
    flag = True
    break
print(2**i)

Submission status: Accepted

Solution code:
n=int(input())
for x in range(8):
 if 2**(x-1)<=n<2**x:print(2**(x-1))

Submission status: Accepted

Solution code:
N = int(input())

ans = 1
ind = 0

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

Submission status: Accepted

Solution code:
N = int(input())
a = [1]
A = 1
while True:
    A *= 2
    if A > N:
        break
    a.append(A)
print(a[-1])

Submission status: Accepted

Solution code:
n = input()
ans = 0
while n!= 0:
	ans += 1
	n//=2
print 1 << (ans-1)

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    N = int(input())
    ans = 0
    for i in range(10):
        if 2 ** i <= N:
            ans = 2 ** i
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
num = 1

for i in range(1, 9):
    if 2**i <= N:
        num = 2**i
print(num)

Submission status: Accepted

Solution code:
N=int(input())
a=[0]
i=0
if N==1:
    print(1)
    exit()
while a[-1]<=100:
    a.append(2**i)
    i+=1
for i in range(1,len(a)):
    if a[i]>N:
        print(a[i-1])
        exit()

Submission status: Accepted

Solution code:
N = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


# --------------------------------------------

dp = None


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

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

    print(2**(ans - 1))


main()

Submission status: Accepted

Solution code:
def count_div(num):
    res = 0
    while num % 2 == 0:
        num //= 2
        res += 1
    return res

n = int(input())

ans = 1
max_cnt = 0
if n >= 2:
    for i in range(2, n+1, 2):
        cnt = count_div(i)
        if cnt > max_cnt:
            max_cnt = cnt
            ans = i

print(ans)

Submission status: Accepted

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

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())
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)  
elif N<= 100:
    print (64)

Submission status: Accepted

Solution code:
#68b
n = int(input())
a=1
while a <= n:
    a*=2
print(a//2)

Submission status: Accepted

Solution code:
s = raw_input()
n = int(s)
dp = [0 for _ in range(n+1)]
dp[0] = 0
dp[1] = 1
maxl, num = 1, 1
for i in range(2, n+1):
    if i % 2 == 1:
        dp[i] = 0
    else:
        dp[i] = dp[i/2] + 1
        if dp[i] > maxl:
            maxl = dp[i]
            num = i
print num

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n, a = int(raw_input()), 2
while a <= n:
    a <<= 1
print a >> 1

Submission status: Accepted

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

Submission status: Accepted

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

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

    max_cnt = 0
    max_num = 1
    for i in range(n, 0, -1):
        num = i
        cnt = 0
        while num % 2 == 0:
            cnt += 1
            num /= 2
        if max_cnt < cnt:
            max_cnt = cnt
            max_num = i
    print(max_num)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from math import log
print(2**int(log(int(input()))/log(2)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = list()

for i in range(10):
    l.append(2**i)

for i in range(10):
    if n - l[i] < 0:
        print(l[i-1])
        break

Submission status: Accepted

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

print(a)

Submission status: Accepted

Solution code:
N = int(input())

binary = [2,4,8,16,32,64]

if N == 1:
  print(1)
else:
  for i in range(len(binary)):
    if binary[len(binary) - 1 - i] <= N:
      print(binary[len(binary) - 1 - i])
      break

Submission status: Accepted

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

Submission status: Accepted

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

print(2**max_count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
s = 0
for i in range(1, N + 1):
	x = 0
	y = i
	while True:
		if y % 2 == 0:
			x += 1
			y = int(y // 2)
		else:
			break
	if x > s:
		s = x
print(2 ** s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
l=[]
a=1
while a<n+1:
    cnt=0
    tmp=a
    while tmp%2==0:
        tmp//=2
        cnt+=1
    a+=1
    l.append(cnt)
print(l.index(max(l))+1)

Submission status: Accepted

Solution code:
import math

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

Submission status: Accepted

Solution code:
"""
https://abc068.contest.atcoder.jp/tasks/abc068_b
"""
a=1
n=int(input())
while a<=n:
    a=a*2
print(int(a/2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

N = int(input())

cnt = 1
while True:
    if 2 ** cnt > N:
        print(2 ** (cnt - 1))
        exit()
    cnt += 1

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:
# input
N = int(input())

a = 0
ans = 1

for i in range(N + 1):
    j = i
    temp = 0
    while j:
        if j % 2 == 0:
            temp += 1
            j = j // 2
        else:
            break
    if temp > a:
        a = temp
        ans = i

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(raw_input())
x=1
while x*2 <= N:
  x *= 2
print x

Submission status: Accepted

Solution code:
N = int(input())
count = 0
result = 0

if N == 1:
    print (1)
else:
    for i in range(1, N+1):
        now_count = bin(i)[::-1].index("1")
        if now_count > count:
            count = now_count
            result = i
    print(result)

Submission status: Accepted

Solution code:
N = int(input())

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

print(int(res/2))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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('{}'.format(n))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

two = 1

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

Submission status: Accepted

Solution code:
def cal(data):
	res = 0
	num = data
	while True:
		if(num%2==0):
			res += 1
			num /= 2
		else:
			return res

def main():
	n = int(input())
	maxe = 0 #割れる回数
	res = 0;
	for i in range(1,n+1):
		if(cal(i)>=maxe): #割れる回数がmaxeよりも多ければ
			maxe = cal(i) #maxeをcal(i)にする
			res = i #resをその時の数字にする
	print(res)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=int(input())
k=0
x=0
while x<=a:
  x=2**k
  k+=1
print(int(x/2))

Submission status: Accepted

Solution code:
n = 101
rec = [0] * 101
num = 0
q = 1
for i in range(n):
    if i % 2 == 0:
        k = 0
        p = i
        while p % 2 == 0 and p > 1:
            p //= 2
            k += 1
        if k > num:
            num = k
            q = i
    rec[i] = q

print(rec[int(input())])

Submission status: Accepted

Solution code:
i = [1,2,4,8,16,32,64,128]
k = int(input())
 
for p in range(len(i)):
  if k == 1:
    print(1)
    break
  elif k < i[p]:
    print(i[p-1])
    break

Submission status: Accepted

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

for i in range(len(lst)):
    if n < lst[i]:
        print(lst[i-1])
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
power = [2,4,8,16,32,64]
if N < 2: print(N)
else: print(max([i for i in power if i <= N]))

Submission status: Accepted

Solution code:
n = int(input())
counter = 0
    
while n != 1:
    n=int(n/2)
    counter += 1
    
print(2**counter)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
print(2**(len("{0:b}".format(N))-1))

Submission status: Accepted

Solution code:
n = int(input())

max_cnt, max_num = 0, 1
for i in range(1, n+1):
    cnt, a = 0, i

    while a%2 == 0:
        a //= 2
        cnt += 1

    if cnt > max_cnt:
        max_cnt = cnt
        max_num = i

print(max_num)

Submission status: Accepted

Solution code:
N=int(input())

if N==1:
  print(1)
else:
  cnt=2
  while cnt<=N:
    if cnt*2 > N:
      break
    else:
      cnt*=2
  print(cnt)

Submission status: Accepted

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

for i in range(n):
    if a <= n:
        a = a*2
    else:
        break

print(int(a/2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = int(input())
max_num = 0
max_count = 0

for i in range(1, x+1):
    count = 0
    flag =1
    num = i
    while flag==1:
        if num%2 == 0:
            count = count+1
            num = num/2
            continue
        else:
            flag=0
            if count>=max_count:
                max_num = i
                max_count = count
                break
            else:
                break

print(max_num)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

now = 1
while(True):
    if now>N:
        print(now//2)
        break
    else:
        now *= 2

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

l = [64, 32, 16, 8, 4, 2, 1]

for i in l:
    if i in range(N + 1):
        print(i)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def count_div(n):
    c = 0
    while n % 2 == 0 and n > 1:
        c += 1
        n = n / 2
    return c


if __name__ == '__main__':
    maximum = (0, 0)
    for i in range(int(input()), 0, -1):
        current = count_div(i)
        if current >= maximum[0]:
            maximum = (current, i)
    print(maximum[1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

def n2(n):
    counter = 0
    while n % 2 == 0:
        n = n / 2
        counter += 1
    return counter

max_resistor = 0
max_n2 = 0
for i in range(1,n+1):
    i_n2 = n2(i)
    if max_n2 <= i_n2:
        max_n2 = i_n2
        max_resistor = i
    
print(max_resistor)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
ans = [0]*n
for i in range(1,n+1):
    ind = i - 1
    while True:
        r = i % 2
        if r == 0:
            ans[ind] += 1
            i = i // 2
        else:
            break

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

Submission status: Accepted

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

Submission status: Accepted

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

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

for num in range(2, N + 1, 2): # N^2/2
    current = 0
    while True:
        if num % 2 == 0:
            current += 1
            num /= 2
        else:
            break
    ans.append(current)

print((ans.index(max(ans)) + 1) * 2)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
two = [1,2,4,8,16,32,64,]
for x in range(1, n+1):
    if x in two:
        hold = x
print(hold)

Submission status: Accepted

Solution code:
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

n = int(arr_data[0][0])


maxdata=0


seq=1

for v in range(1,1+n):
    
#    print(v)
    
    vtemp=v
    cnt=0
    while(vtemp%2==0):
#        
    
        cnt+=1
#        print(v,vtemp,cnt,maxdata)
        vtemp=vtemp/2
    
    else:   
        
#        print(maxdata,cnt,v)
        if maxdata<cnt:

            maxdata=cnt
            seq=v

        

print(seq)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
print(1<<int(math.log2(int(input()))))

Submission status: Accepted

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

# AtCoder Beginner Contest
# Problem B

if __name__ == '__main__':
    number = int(input())

    count = 0

    while 2 ** count <= number:
        count += 1

    print(2 ** (count - 1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
n = int(input())
for i in range(8):
    if 2**(i+1)>n:
        print(2**i)
        break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
L=[1,2,4,8,16,32,64]
l=0
N=int(input())
while l < len(L):
    if N < L[l]:
        print(L[l-1])
        break
    else:
        l += 1
if l == len(L):
    print(L[-1])

Submission status: Accepted

Solution code:
from math import log2
i = int(input())
j = sorted([2 ** x for x in range(7)] + [i])
if log2(i) % 1 == 0:
  print(i)
  exit()
print(j[j.index(i) - 1])

Submission status: Accepted

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