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

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

Submission status: Accepted

Solution code:
N = int(input())
for i in range(0,8):
    if 2**i <= N:
        ans = 2**i
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())
even_A = list(range(1, N+1))
dic = {}
for a in even_A:
  x = a
  cnt = 0
  while x%2 == 0:
    x /= 2
    cnt += 1
  dic[a] = cnt

ans = sorted(dic.items(), key=lambda x:x[1])[-1]

print(ans[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())

cnt=0
for i in range(1,n+1):
    cnt_tmp=0
    tmp=i
    while tmp%2==0:
        cnt_tmp+=1
        tmp=tmp/2
    cnt=max(cnt, cnt_tmp)
    

print(2**cnt)

Submission status: Accepted

Solution code:
n=int(input())
a=len(bin(n))-3
print(n>>a<<a)

Submission status: Accepted

Solution code:
N = int(input())

result = 0
i = 0

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

Submission status: Accepted

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

for i in range(1,N+1):
    ans=0
    while(1):
        if i%2!=0:
            l.append(pow(2,ans))
            break
        else:
            i/=2
            ans+=1
print(max(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#068 b-break number
n=int(input())
num=[1,2,4,8,16,32,64]
for i in range(1,n+1)[::-1]:
    if i in num:
        ans=i
        break
print(ans)

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

Submission status: Accepted

Solution code:
N = int(input())
result = 1
i = 0
x = 0

while True:
  if (2 ** i) <= N:
    i += 1
  else:
    break

print(2 **(i-1))

Submission status: Accepted

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

j=0
a=0
while l[j]<=n:
    a=l[j]
    j+=1
print(a)

Submission status: Accepted

Solution code:
import math

N = int(input())
print(pow(2,int(math.log2(N))))

Submission status: Accepted

Solution code:
n = int(input())

for i in range(1,10):
    if 2**i <= n:
        continue
    else:
        print(2**(i-1))
        break

Submission status: Accepted

Solution code:
n = int(input())

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

Submission status: Accepted

Solution code:
s=int(input())

counts = 0
ans = 1

for i in range(s + 1):
  k = i
  count = 0
  while(True):
    if i % 2 == 1 or i == 0:
      break

    i = i / 2
    count += 1
  
  if counts < count:
    counts = count
    ans = k

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
 
import math
import itertools
import sys
import copy
 
# 入力
#N, K = map(int, input().split())
#L = list(map(int, input().split()))
N = int(input())
#S = str(input())

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

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    tmp = [2**6, 2**5, 2**4, 2**3, 2**2, 2, 1]
    for t in tmp:
        if N >= t:
            print(t)
            exit()
if __name__ == '__main__':
    main()

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())
print(2**(len(bin(N))-3))

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())
ans=0
for i in range(7):
    if 2**i<=n:
        ans=2**i
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:
import math
n=int(input())
print(2**math.floor(math.log(n,2)))

Submission status: Accepted

Solution code:
N = int(input())

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

Submission status: Accepted

Solution code:
import sys
from math import log2, floor

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

def main():
    x = floor(log2(n))
    return 2 ** x

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

Submission status: Accepted

Solution code:
N = int(input())

ans = 0

for i in range(N + 1):
    t = 0
    while i % 2 == 0  and  i != 0:
        i /= 2
        t += 1
        ans = max(ans, t)
print(2**int(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

n = int(input())
a = 0
while 2 ** (a + 1) <= n:
    a += 1
print(2 ** a)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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

N=one_int()

import math

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

Submission status: Accepted

Solution code:
n = int(input())

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

print(ans)

Submission status: Accepted

Solution code:
a=int(input())
saiko=0
count=0
for j in range(1,a+1):
  count=0
  while j%2==0:
    count+=1
    j=j//2
  saiko=max(saiko,count)
print(2**saiko)

Submission status: Accepted

Solution code:
n = int(input())
cnt = 0
while (n >= 1):
    n //= 2
    cnt += 1
print(1 << cnt - 1)

Submission status: Accepted

Solution code:
a = int(input())
s = 0
d = 2
while 1:
    s += 1
    k = d ** s
    if k > a:
        print(d ** (s-1))
        break

Submission status: Accepted

Solution code:
n = int(input())

ans = 1
while True:
    if ans > n:
        print(ans//2)
        import sys
        sys.exit()
    if ans == n:
        print(ans)
        import sys
        sys.exit()
    ans *= 2

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
cnt = 0
while 2 ** cnt <= n:
    cnt += 1
print(2 ** (cnt - 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:
n = int(input())
for i in range(7):
    if 2 ** i <= n:
        ans = 2 ** i
print(ans)

Submission status: Accepted

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

for i in range(1,N+1):
    t = 0
    while i % 2 == 0:
        i //= 2
        t += 1
    S.append(t)
 
p = max(S)
print(2 ** p)

Submission status: Accepted

Solution code:
n = int(input())

count1 = 0

for i in range(1,n+1):
  a = i%2
  b = i/2
  count = 1
  while a ==0:
    a = b%2
    b = b/2
    count += 1
  if count > count1:
    count1 = count
    max_num = i
print(max_num)

Submission status: Accepted

Solution code:
n = int(input())

ans = 0
cmax = -1
for ii in range(1, n + 1):
    c = 0
    i = ii
    while i > 0:
        if i % 2 == 0:
            i = i // 2
            c += 1
        else:
            break
    if c > cmax:
        ans = ii
        cmax = c
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
L = [2**x for x in range(0,7)]

ans = 0
for l in L:
    if n >= l:
        ans = l

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

Submission status: Accepted

Solution code:
N = int(input())

isnext = 0
ans = 0

while isnext == 0:
        for i in range(N,-1,-1):
                if(False ==  (i & (i-1))):
                        ans = i
                        isnext = 1
                        break
                else:
                        next

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

    best = 0
    best_num = 1
    for i in range(n):
        k = i + 1
        c = 0
        while k % 2 == 0:
            k //= 2
            c += 1
        if c > best:
            best = c
            best_num = i + 1

    print(best_num)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
n=int(input())
if(n==0):
    print(0)
    exit()
if(n==1 or n==2):
    print(1)
    exit()

x=2**1
for i in range(2,8):
    x=2**i
    if(x>n):
        print(x//2)
        exit()

Submission status: Accepted

Solution code:
n = int(input())

count_dict = {}

for num in range(1, n + 1):
    count_dict[num] = 0
    tmp = num
    while True:
        if tmp % 2 == 0:
            tmp /= 2
            count_dict[num] += 1
        else:
            break

max_count = max(count for count in count_dict.values())
result = [k for k, v in count_dict.items()
          if v == max_count][0]

print(result)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def main():
    n=int(input())
    s=1
    while s*2<=n:
        s*=2
    print(s)
main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#n = int(input())
#n,k = map(int,input().split())
#x = list(map(int,input().split()))


n = int(input())

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

print(i//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:
n = int(input())
ans = 1
bcnt = 0
for i in range(1,n + 1):
  cnt = 0
  #print(i)
  a = i
  while a % 2 == 0:
    cnt += 1
    a = a // 2
  if cnt > bcnt:
    ans = i
    bcnt = cnt
    #print(i)
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
N = int(input())
a = [0, -1] 
for i in range(N):
        tmp = N - i 
        cnt = 0 
        while tmp > 1:
                if tmp % 2 != 0:
                        break
                else:
                        cnt += 1
                        tmp /= 2
        if a[1] < cnt:
                a = [N - i, cnt] 
print(a[0])

Submission status: Accepted

Solution code:
n = int(input())

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

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:
l = list()
n = int(input())
original_list = list(range(1,n+1))
for x in original_list:
      ans = 0
      while x % 2 == 0:
        x = x / 2
        ans = ans + 1
      l.append(ans)

a = l.index(max(l))
print(original_list[a])

Submission status: Accepted

Solution code:
print(2 ** (len(format(int(input()), "b")) - 1))

Submission status: Accepted

Solution code:
N = int(input())
result = 0
for i in range(7):
  if N >= 2**i:
    result = 2**i
  else:
    None
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def div2_count(n):
  if n % 2 != 0: return 0
  else: return 1 + div2_count(n / 2)

N = int(input())
ans = 1
count = 0

for i in range(N, 1, -1):
  tmp = div2_count(i) 
  if tmp > count: 
    ans = i
    count = tmp
    
print(ans)

Submission status: Accepted

Solution code:
N=int(input())
cnt_list={}

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

print(max(cnt_list,key=cnt_list.get))

Submission status: Accepted

Solution code:
N = int(input())
range_N = range(1,N+1) # 1<=M<=100
target = 1
for i in range_N:
  if 2 ** i <= N :
    target = 2 ** i
print(target)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())

target = 1
for i in range(1, N+1):
    if 2 ** i <= N:
        target = 2 ** i

print(target)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
x=1
cou=0
while x <= N:
    x *= 2
    cou += 1
    
print(2**(cou-1))

Submission status: Accepted

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

while max_n * 2 <= N:
    max_n *= 2

print(max_n)

Submission status: Accepted

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

Submission status: Accepted

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


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

for i in range(1, n+1):
    a = divide_two_count(i)
    list.append(a)

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

Submission status: Accepted

Solution code:
n = int(input())
cnt = 1
while 2**cnt <= n:
    cnt += 1
print(2**(cnt-1)) if n != 1 else print(1)

Submission status: Accepted

Solution code:
a=[2**i for i in range(8)]
import bisect
n=int(input())
s=bisect.bisect_left(a,n)
if n==a[s]:
    print(n)
    exit()
print(a[s-1])

Submission status: Accepted

Solution code:
##### 解けた #####

from math import log,floor

N=int(input())
print(2**floor(log(N,2)))

Submission status: Accepted

Solution code:
n = int(input())
ans = list(range(n+1))
for i in ans:
    if ans[i]%2!=0:
        ans[i]=0
    else:
        count = 0
        while(True):
            if ans[i]%2 != 0 or ans[i] == 0:
                ans[i] = count
                break
            else:
                ans[i]/=2
                count+=1
ans[0] = -1
print(ans.index(max(ans)))

Submission status: Accepted

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

    ans = 2 ** i
print(ans)

Submission status: Accepted

Solution code:
#Break Number
N = int(input())
judge = 1
for i in range(7):
    if N < 2**i:
        print(2**(i-1))
        judge = 0
        break
        
if judge == 1:
    print(64)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
result = {}
for i in range(1, N + 1):
    result[i] = 0
    tmp = i
    while True:
        if tmp % 2 == 0:
            tmp = tmp / 2
            result[i] += 1
        else:
            break
print(sorted(result.items(), key=lambda x: -x[1])[0][0])

Submission status: Accepted

Solution code:
N = int(input())
res = [x for x in range(1, N + 1)]
result = {}
for i in res:
    result[i] = 0
    tmp = i
    while True:
        if tmp % 2 == 0:
            tmp = tmp / 2
            result[i] += 1
        else:
            break
print(sorted(result.items(), key=lambda x: -x[1])[0][0])

Submission status: Accepted

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

for i in num_list:
  if N>=i:
    print(i)
    exit(0)

print(0)

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
i = 1
while True:
    if 2**i > n:
        break
    i += 1
print(2**(i-1))

Submission status: Accepted

Solution code:
N=int(input())
ans=[]
for k in range(1,N+1):
    M=0
    for i in range(7):
        if k%(2**(i+1))==0:
            M+=1
    ans.append(M)
print(ans.index(max(ans))+1)

Submission status: Accepted

Solution code:
n = int(input())
  
def divide_count(c):
  count = 0
  while True:
    if c % 2 == 0:
      c = c / 2
      count += 1
    else:
      return count
    
answer = 1
dc = 0
before = 0
for i in range(n):
  count = i+1
  dc = divide_count(count)
  if before < dc:
    answer = count
    before = dc
print(answer)

Submission status: Accepted

Solution code:
N = int(input())
max = -1
ans = -1

for i in range(N):
    count = 0
    k = i+1
    while k % 2 == 0:
        count = count +1
        k = k/2

    if count >= max:
        max = count
        ans = i+1

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

#print('-----')
max = -1
ans = -1

for i in range(n):
	count = 0
	k = i+1
	#print('-------')
	#print(k)
	while k%2 == 0:
		count = count+1
		k = k/2
		#print(count)
	if count >= max:
		max = count
		ans = i+1

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

N = int(input())

two = 0

while N >= 2 ** two:
    two += 1

print(2 ** (two - 1))

Submission status: Accepted

Solution code:
n = int(input())
ls = [[2,1]]
two = 2
i = 1
while True:
    two *= 2
    i += 1
    if two > 200:
        break
    ls.append([two,i])
    
if n == 1:
    print(1)
else:
    for i in range(len(ls)):
        if ls[i][0] > n:
            print(ls[i-1][0])
            break

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

num = int(input())
two = 0

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

print(2 ** (two - 1))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
if N == 1:
    print(1)
    exit()
ans = 0
max_tmp = 0
for i in range(1,N+1):
    t = i
    tmp = 0
    while True:
        if t % 2 == 1:
            break
        t /= 2
        tmp += 1
    if max_tmp < tmp:
        ans = i
        max_tmp = tmp
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
if n<2:
  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())
for i in range(7):
    a = 2**i
    if a <= n:
        ans = a
print(ans)

Submission status: Accepted

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

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

max_count = 0
max_num = 1
for num in range(1, N+1):
    num_ = num
    count = 0
    rest = 0
    while rest == 0:
        rest = num_ % 2
        num_ = num_ / 2
        if rest == 1:
            continue
        else:
            count += 1
    if count > max_count:
        max_count = count
        max_num = num
print(max_num)

Submission status: Accepted

Solution code:
def examB():
    N = I()
    ansC = [(i+1) for i in range(N)]
    k = 0
    while(len(ansC)>=2):
        cur = []
        for i in ansC:
            if i % 2 == 0:
                cur.append(i // 2)
        ansC = cur
        k +=1
        if len(ansC)==1:
            break
    ans = 2**k
    print(ans)

import sys
import copy
import bisect
import heapq
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examB()

Submission status: Accepted

Solution code:
# ABC 068: B – Break Number
n = int(input())
candidate = 1

if n == 1:
    print(1)
else:
    while candidate <= n:
        candidate *= 2
    print(candidate // 2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = int(input())
s = 2
for i in range(1,A):
  if A == 1:
    print(1)
    break;
  elif A == 2:
    print(2)
    break;
  elif s <= A:
    s = 2**i
  else:
    break;
      
print(s//2)

Submission status: Accepted

Solution code:
def main():
  N = int(input())
  num = 0
  answer = 0
  for i in range(1, N + 1):
    count = calc(i)
    if num <= count:
      num = count
      answer = i
  
  print(answer)

def calc(i):
  answer = 0
  j = i
  while j % 2 == 0:
    j //=  2
    answer += 1
  return answer

main()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n=int(input())
tmp=0
count=0
ans=0
wer=0
if n==1:
    print(1)
else:
    for i in range(1,n+1):
    #print(count,ans,wer)
        tmp=i
        for j in range(n):
            if tmp%2==0:
                count+=1
                tmp=tmp//2
            else:
                if count>ans:
                    ans=count
                    wer=i
                count=0
                break
    print(wer)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
ls = []

for i in range(1, n+1):
    cnt = 0
    while i % 2 == 0:
        i /= 2
        cnt += 1
    ans = max(ans, cnt)
    ls.append(ans)

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

Submission status: Accepted

Solution code:
n=int(input())
i=1
h=1
count=0
l=[]
while h<=n:
    if i%2==0:
        count+=1
        i=i/2
    else:
        l.append(count)
        h+=1
        i=h
        count=0
print(l.index(max(l))+1)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
counts = []
for i in range(1, n+1):
    count = 0
    while i % 2 == 0:
        count+=1
        i /= 2
    counts.append(count)
print(np.argmax(counts)+1)

Submission status: Accepted

Solution code:
N = int(input())
s = [i for i in range(1,N+1)]
counter = 0

while True:
    if 2 ** (counter+1) in s:
        counter += 1
    else:
        break
        
print(2 ** counter)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
print(1<<N.bit_length()-1)

Submission status: Accepted

Solution code:
N = int(input())
pow2 = [2**i for i in range(7)]
ans = 0
if N >= 2:
    for i in range(N+1):
        if i in pow2:
            ans = max(i,ans)
else:
    ans = 1
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
n2s = [2**i for i in range(10)][::-1]
for n2 in n2s:
    if n2 <= N:
        print(n2)
        break

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
res = 0
cc = 0
for i in range(1,n+1):
    tmp = i
    cnt = 0
    while True:
        if tmp%2==0:
            tmp //= 2
            cnt += 1
        else:
            break
    if cnt >= cc:
        cc = cnt
        res = i
print(res)

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 = 0
maxcnt = -1
for i in range(1,N+1):
    cnt = 0
    now = i
    while now % 2 == 0:
        now /= 2
        cnt += 1
    if maxcnt < cnt:
        maxcnt = cnt
        ans = i
print(ans)

Submission status: Accepted

Solution code:
import bisect    
ans_list = [1,2,4,8,16,32,64]

n = int(input())
idx = bisect.bisect(ans_list,n)

print(ans_list[idx-1])

Submission status: Accepted

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

for i in range(1,N+1):
    c=list(str(bin(i))).count("0")
    if cnt < c:
        cnt=c
        ans=i
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
cnt=0
for x in range(1,N+1):
    tmp=0
    while True:
        if x%2==0:
            if x == 1:
                break
            x=x//2
            tmp+=1
        else:
            break
    if cnt<=tmp:
        cnt=tmp
print(2**cnt)

Submission status: Accepted

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

print(2**(k-1))

Submission status: Accepted

Solution code:
N = int(input())
maxCount = 0
ans = 0
for i in range(1, N+1):
    tmpCount = 0
    j = i
    while True:
        if j % 2 != 0:
            break
        j = j/2
        tmpCount += 1
    
    if maxCount <= tmpCount:
        maxCount = tmpCount
        ans = i

print(ans)

Submission status: Accepted

Solution code:
n = int(input())

ans = 1

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

Submission status: Accepted

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

n = int(input().rstrip('\n'))
log_floor = math.floor(math.log(n, 2))
res = 0
while True:
    if res == log_floor: print(2 ** res); exit()
    res += 1

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
n = int(input())
a =[1,2,4,8,16,32,64,128]
ans = bisect.bisect_right(a,n)
print (a[ans-1])

Submission status: Accepted

Solution code:
import collections

N = int(input())

#素因数分解
def factorize(n):
    b = 2
    fct = []
    while b * b <= n:
        while n % b == 0:
            n //= b
            fct.append(b)
        b = b + 1
    if n > 1:
        fct.append(n)
    return fct

max_devide = 0
ans = 1
for i in range(N+1):
    
    if factorize(i).count(2) > max_devide:
        max_devide = factorize(i).count(2)
        ans = i

print(ans)

Submission status: Accepted

Solution code:
n = int(input())
list_n = [2 ** i for i in range(1, 8)]
bag =[1]
for i in list_n:
    if n >= i:
        bag.append(i)
print(max(bag))

Submission status: Accepted

Solution code:
a = int(input())

for i in range(8):
    if a >= 2**i:
        pass
    else:
        print(2**(i-1))
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
tmp = 2
while tmp <= N:
    tmp += tmp
print(int(tmp/2))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
r = 0
res = 1
for i in range(1, N + 1):
  t = i
  c = 0
  while t % 2 == 0:
    c += 1
    t //= 2
  if c > r:
    res = i
    r = c
print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

original = [i + 1 for i in range(n)]
numbers = [i + 1 for i in range(n)]

count = [0 for i in range(n)]

while any(i % 2 == 0 for i in numbers):
    for j,number in enumerate(numbers):
        
        if number % 2 == 0 :
            numbers[j] = number / 2
            count[j] += 1

print (original[count.index(max(count))])

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
powers_2 = [2,4,8,16,32,64]
for i in range(len(powers_2)):
    if n == 0:
        ans = n
        break
    elif n == 1:
        ans = n
        break
    elif powers_2[i] <= n:
        ans = powers_2[i]
        continue
    elif powers_2[i] > n:
        ans = powers_2[i - 1]
        break
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
ans = 0
anss = 0
for i in range(1,n+1):
    t = 0
    while i%2 == 0:
        t +=1
        i = i/2
    if t > ans:
        ans = t
        anss = i*(2**t)
    else:
        pass

if n == 1:
    anss = 1
print(int(anss))