Problem:
Score : 200 points

Problem Statement

Takahashi loves numbers divisible by 2.

You are given a positive integer N. Among the integers between 1 and N (inclusive), find the one that can be divisible by 2 for the most number of times. The solution is always unique.

Here, the number of times an integer can be divisible by 2, is how many times the integer can be divided by 2 without remainder.

For example,

6 can be divided by 2 once: 6 -> 3.

8 can be divided by 2 three times: 8 -> 4 -> 2 -> 1.

3 can be divided by 2 zero times.

Constraints

1 ≤ N ≤ 100

Input

Input is given from Standard Input in the following format:

N

Output

Print the answer.

Sample Input 1

7

Sample Output 1

4

4 can be divided by 2 twice, which is the most number of times among 1, 2, ..., 7.

Sample Input 2

32

Sample Output 2

32

Sample Input 3

1

Sample Output 3

1

Sample Input 4

100

Sample Output 4

64

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Accepted)

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.util.Arrays;

public class Main {

	private static final int MOD = 1000000007;
	private static final int intINF = Integer.MAX_VALUE;
	private static final long longINF = Long.MAX_VALUE;

	private static void solve() {
		int n =sc.nextInt();
		int s = 1;
		while(s<=n)s*=2;
		pw.print(s/2);
	}

	// TEMPLATE

	private static myScanner sc;
	private static PrintWriter pw;

	private static final int numberOfTests = 1;

	private static final String nameOfInAndOutFile = "";
	private static final String fullNameInputFile = nameOfInAndOutFile + ".in";
	private static final String fullNameOutputFile = nameOfInAndOutFile + ".out";

	public static void main(String[] args) throws IOException {
		if (nameOfInAndOutFile.length() == 0) {
			setDefaultInAndOutPut();
		} else {
			setInAndOutPutFromFile();
		}
		for (int test = 1; test <= numberOfTests; test++) {
			solve();
			pw.flush();
		}

		pw.close();
	}

	private static void setDefaultInAndOutPut() {
		sc = new myScanner(new BufferedReader(new InputStreamReader(System.in)));
		pw = new PrintWriter(System.out);
	}

	private static void setInAndOutPutFromFile() throws IOException {
		sc = new myScanner(new BufferedReader(new FileReader(new File(fullNameInputFile))));
		pw = new PrintWriter(new File(fullNameOutputFile));
	}
}

class myScanner {
	private char[] buffer = new char[1 << 8];
	private int pos = 1;

	private BufferedReader reader;

	public myScanner(BufferedReader reader) {
		this.reader = reader;
	}

	public boolean hasNext() {
		return pos > 0;
	}

	private void loadBuffer() {
		pos = 0;
		try {
			for (int i; (i = reader.read()) != -1;) {
				char c = (char) i;
				if (c != ' ' && c != '\n' && c != '\t' && c != '\r' && c != '\f') {
					if (pos == buffer.length)
						buffer = Arrays.copyOf(buffer, 2 * pos);
					buffer[pos++] = c;
				} else if (pos != 0)
					break;
			}
		} catch (IOException e) {
			throw new UncheckedIOException(e);
		}
	}

	public String current() {
		return String.copyValueOf(buffer, 0, pos);
	}

	public String next() {
		loadBuffer();
		return current();
	}

	public String nextLine() {
		try {
			return reader.readLine();
		} catch (IOException e) {
			throw new UncheckedIOException(e);
		}
	}

	public int nextInt() {
		return nextInt(10);
	}

	public long nextLong() {
		return nextLong(10);
	}

	public int nextInt(int radix) {
		loadBuffer();
		int result = 0;
		int i = buffer[0] == '-' || buffer[0] == '+' ? 1 : 0;
		for (checkValidNumber(pos > i); i < pos; i++) {
			int digit = buffer[i] - '0';
			checkValidNumber(0 <= digit && digit <= radix - 1);
			result = result * radix + digit;
		}
		return buffer[0] == '-' ? -result : result;
	}

	public long nextLong(int radix) {
		loadBuffer();
		long result = 0;
		int i = buffer[0] == '-' || buffer[0] == '+' ? 1 : 0;
		for (checkValidNumber(pos > i); i < pos; i++) {
			int digit = buffer[i] - '0';
			checkValidNumber(0 <= digit && digit <= radix - 1);
			result = result * radix + digit;
		}
		return buffer[0] == '-' ? -result : result;
	}

	public int[] nextArrayInts(int size) {
		int[] input = new int[size];
		for (int i = 0; i < size; i++)
			input[i] = nextInt();
		return input;
	}

	public long[] nextArrayLongs(int size) {
		long[] input = new long[size];
		for (int i = 0; i < size; i++)
			input[i] = nextLong();
		return input;
	}

	public double nextDouble() {
		loadBuffer();
		long result = 0;
		int i = buffer[0] == '-' || buffer[0] == '+' ? 1 : 0;
		long round = 1;
		final int radix = 10;
		boolean hasPoint = false;
		for (checkValidNumber(pos > i); i < pos; i++) {
			int digit = buffer[i] - '0';
			checkValidNumber((0 <= digit && digit <= radix - 1) || (!hasPoint && digit == -2));
			if (digit == -2)
				hasPoint = true;
			else {
				if (hasPoint)
					round *= radix;
				result = result * radix + digit;
			}

		}
		return buffer[0] == '-' ? -result / (1.0 * round) : result / (1.0 * round);
	}

	private void checkValidNumber(boolean condition) {
		if (!condition)
			throw new NumberFormatException(current());
	}
}