jiahuimbzuai/CoQuIR huggingface dataset:
//  [cpp]
/*
                IftekharMd.Shishir
                Dept. of Information and Communication Engineering
                University of Rajshahi
*/

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>

#define ll  long long
#define ull  unsigned long long
#define ld  long double
#define f(i,n)  for(i=0;i<n;i++)
#define F(i,n)  for(i=n-1;i>=0;i--)
#define fa(i,a,b)  for(i=a;i<=b;i++)
#define Fa(i,a,b)  for(i=a;i>=b;i--)
#define printArray(i,a,n)  f(i,n)cout<<a[i]<<" "; cout<<endl;
#define printSet(a)  for(auto setData:a) cout<<setData<<" ";cout<<endl;
#define printMap(a)  for(auto mapData:a) cout<<mapData.first<<" "<<mapData.second<<endl;
#define printVector(a)  for(auto vectorData:a)cout<<vectorData<<" ";cout<<endl;
#define printLinkedList()  temp=head;while(temp){cout<<temp->data<<" ";temp=temp->post;} cout<<endl;

#define pb(x)  push_back(x)
#define all(a)  a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()

#define bs  binary_search
#define lb  lower_bound
#define ub  upper_bound
#define mp  make_pair
#define TxtIO  freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define TxtTest freopen("C:/Users/Iftekhar/Documents/what/input.txt", "r", stdin);
#define FastIO  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
#define TestCase  ll t;cin>>t;while(t--)
#define points(x)  fixed<<setprecision(x)
#define scd(a,x,y)  a/__gcd(x,y);
#define nl  cout<<endl;
#define done  return 0

const ld PI= 3.14159265358979323846264338327950288;  //2*acos(0.0);
const long long MOD= 1000000007;
const long long MAX = 32000;

// stringstream demo(str);  demo >> x;
// stringstream demo;  demo << x;  name=demo.str();

using namespace __gnu_pbds;
using namespace std;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main()
{
        FastIO;
        //TxtTest;
        ll n,i;
        cin>>n;
        if(n==1) {
                cout<<1<<endl;
                done;
        }
        ll a[7]={2,4,8,16,32,64,128};
        for(i=1;i<7;i++){
                if(n>=a[i] && n<a[i+1]){
                        cout<< a[i] <<endl;
                        done;
                }
        }
        done;
}
//  [c]
#include <ctype.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MOD 1000000007
#define ll long long

int main(){
    int n,i;
    scanf("%d",&n);
    i=1;
    while(2*i<=n){
        i*=2;
    }
    printf("%d\n",i);
    return 0;
}
//  [c]
#include <stdio.h>


int main(void)
{
	int n;
	scanf("%d", &n);

	int i;
	for (i = 1; i <= n; i *= 2);
	printf("%d\n", i/2);
	return 0;
}
//  [c]
#include <stdio.h>

int main(void){
    int N;
    scanf("%d", &N);

    if(N>=64){
        printf("64\n");
    }else if(N>=32){
        printf("32\n");
    }else if(N>=16){
        printf("16\n");
    }else if(N>=8){
        printf("8\n");
    }else if(N>=4){
        printf("4\n");
    }else if(N>=2){
        printf("2\n");
    }else{
        printf("1\n");
    }
}
//  [c]
#include <stdio.h>

int main(void){
int n,i = 0;
scanf("%d", &n);

for(i=1;i<=n;){
  i = 2*i;
  if((2*i)>n) break;
  //ans++;
}
printf("%d",i);
return 0;
}
//  [c]
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
//qsort用 降順ソート
int comp(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}
int main(void)
{
    int N;
    int i;
    int ret = 0;
    scanf("%d",&N);
    if(N==1){
        printf("1\n");
        return 0;
    }
    // N以下の2の累乗を求める
    for(i=0;i<8;i++){
        if(pow(2,i)<N){
            ret = pow(2,i);
        }else{
            break;
        }
    }
    printf("%d\n",ret);
    return 0;
}
//  [c]
#include <stdio.h>
#include <math.h>

int main(void) {
  int input;
  fscanf(stdin, "%d", &input);
  
  // 2の累乗に最も近い値を選択
  for (int i = input; i > 0; i--) {
    printf("%d", i);
    if (log2(i) == 0.0 // 1
        || log2(i) == 1.0 // 2
        || log2(i) == 2.0 // 4
        || log2(i) == 3.0 // 8
        || log2(i) == 4.0 // 16
        || log2(i) == 5.0 // 32
        || log2(i) == 6.0 // 64
        ) {
      printf("%d\n", i);
      break;
    }
  }
  return 0;
}
//  [javascript]
"use strict";

var input = require("fs").readFileSync("/dev/stdin", "utf8");
var cin = input.split(/ |\n/),
    cid = 0;

function next() {
    return +cin[cid++];
} // number一個取得
function nextstr() {
    return cin[cid++];
} // 文字列一個取得
function nextbig() {
    return BigInt(cin[cid++]);
} // BigInteger一個取得
// 長さnの配列として取得。aは文字列フラグ
function nexts(n, a) {
    return a ? cin.slice(cid, cid += n) : cin.slice(cid, cid += n).map(a => +a);
}
// 長さnのBigInt配列として取得。
function nextsbig(n) {
    return cin.slice(cid, cid += n).map(a => BigInt(a));
}
// w個ずつを組にして長さhの配列。aは文字列フラグ。
function nextm(h, w, a) {
    var r = [],
        i = 0;
    if (a)
        for (; i < h; i++) r.push(cin.slice(cid, cid += w));
    else
        for (; i < h; i++) r.push(cin.slice(cid, cid += w).map(a => +a));
    return r;
}
// 多次元配列。v,a1,a2,a3 なら、3次元。[[値vで長さa3の配列]をa2個並べた配列]をa1個並べた配列。
function xArray(v) {
    var a = arguments,
        l = a.length,
        r = "Array(a[" + --l + "]).fill().map(x=>{return " + v + ";})";
    while (--l) r = "Array(a[" + l + "]).fill().map(x=>" + r + ")";
    return eval(r);
}


console.log(main().toString());

function main() {
    let n = next();
    let i;
    for (i = 1; i * 2 <= n; i = i * 2) {}
    return i
}
//  [javascript]
"use strict";

function Main(input) {
  const n = parseInt(input, 10);
  const nums = [64, 32, 16, 8, 4, 2, 1];

  const ans = nums.find(v => n >= v);
  console.log(ans);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
'use strict'

const main = input => {
	const n = parseInt(input.trim(), 10)
	let maxNum = 0
	let maxCnt = -1

	for (let i = 1; i <= n; i++) {
		let tmpNum = i  
		let tmpCnt = 0

		while (true) {
			if (tmpNum % 2 === 1) break
			tmpNum /= 2
			tmpCnt++
		}

		if (tmpCnt > maxCnt) {
			maxNum = i
			maxCnt = tmpCnt
		}
	}

	console.log(maxNum)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'))
//  [javascript]
function main(input) {
  const N = input;
  let n = 0;
  
  // Math.pow(x, y) xのy乗
  
  while(true) {
  	if (Math.pow(2, n) < N) {
      n++;
    } else if (Math.pow(2, n) === N) {
      break;
    } else {
      //一回分多くたされているから引く
      n--;
      break;
    }
  }
  
  console.log(Math.pow(2, n));
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(input) {
  input = input * 1;
  let biggest = 0;
  let biggestId = 0;
  for (let i = 1;i <= input;i++) {
    let nowNum = i;
    let count = 0;
    while (nowNum % 2 === 0) {
      nowNum = nowNum / 2;
      count++;
    }
    if (biggest < count) {
      biggest = count;
      biggestId = i;
    }
  }
  console.log(biggestId);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [javascript]
function main(input) {
  input = input * 1;
  let biggest = 0;
  let biggestId = 0;
  for (let i = 0;i < input;i++) {
    let nowNum = i;
    let count = 0;
    while (nowNum % 2 === 0 && nowNum !== 0) {
      nowNum = nowNum / 2;
      count++;
    }
    if (biggest < count) {
      biggest = count;
      biggestId = i;
    }
  }
  console.log(biggestId);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	var wtr = bufio.NewWriter(os.Stdout)
	var scanner = bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanLines)
	var N int
	if scanner.Scan() {
		str := scanner.Text()
		N, _ = strconv.Atoi(str)
	}
	s := fmt.Sprintf("%b", N)
	//fmt.Printf("%b\n", N)
	ans := len(s) - 1
	p := math.Pow(2, float64(ans))
	fmt.Fprintln(wtr, int(p))
	_ = wtr.Flush()
}

func max(a int, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func min(a int, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}
//  [go]
package main

// Solution for https://atcoder.jp/contests/abc068/tasks/abc068_b

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

type contest struct {
	in  io.Reader
	out io.Writer
}

func (con *contest) Scan(a ...interface{}) (int, error) {
	return fmt.Fscan(con.in, a...)
}
func (con *contest) Scanln(a ...interface{}) (int, error) {
	return fmt.Fscanln(con.in, a...)
}
func (con *contest) Scanf(f string, a ...interface{}) (int, error) {
	return fmt.Fscanf(con.in, f, a...)
}
func (con *contest) Print(a ...interface{}) (int, error) {
	return fmt.Fprint(con.out, a...)
}
func (con *contest) Println(a ...interface{}) (int, error) {
	return fmt.Fprintln(con.out, a...)
}
func (con *contest) Printf(f string, a ...interface{}) (int, error) {
	return fmt.Fprintf(con.out, f, a...)
}
func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	con := &contest{in: in, out: out}
	con.main()
}

func (con *contest) main() error {
	var n int
	con.Scan(&n)
	m := n
	for i := 2; i <= n; i <<= 1 {
		m = i
	}
	con.Println(m)
	return nil
}
//  [go]
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	if n == 1 {
		fmt.Println(1)
	}else if n >= 2 && n < 4{
		fmt.Println(2)
	}else if n >= 4 && n < 8{
		fmt.Println(4)
	}else if n >= 8 && n < 16{
		fmt.Println(8)
	}else if n >= 16 && n < 32{
		fmt.Println(16)
	}else if n >= 32 && n < 64{
		fmt.Println(32)
	}else if n >= 64 && n <= 100{
		fmt.Println(64)
	}
}
//  [go]
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func contains(target string, list []string) bool {
	for _, r := range list {
		if target == r {
			return true
		}
	}
	return false
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()

	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextF64() float64 {
	sc.Scan()

	i, e := strconv.ParseFloat(sc.Text(), 64)
	if e != nil {
		panic(e)
	}
	return i
}

func isInteger(x float64) bool {
	return math.Floor(x) == x
}

func Ave(s []int) int {
	val := 0
	for _, i := range s {
		val += i
	}
	return int(val / len(s))
}
func cal(i int) (sum int) {
	for i != 0 {
		sum += i % 10
		i /= 10
	}
	return
}
func max(a []int) (idx int, val int) {
	max := a[0]
	idx = 0
	for j, i := range a {
		if max < i {
			max = i
			idx = j
		}
	}
	return idx, max
}

func draw(i int, a []int) (l []int) {
	// p = a[i]
	for j := i; j < len(a); j++ {
		if j != len(a)-1 {
			a[j] = a[j+1]
		} else if j == len(a)-1 {
			a = a[:len(a)-1]
		}
	}
	return a
}

func main() {
	sc.Split(bufio.ScanWords)
	// sc.Buffer([]byte{}, math.MaxInt64)
	// a := make([][]int, 3)
	// for i := 0; i < 3; i++ {
	// 	a[i] = make([]int, 3)
	// }
	// for i := 0; i < 3; i++ {
	// 	for j := 0; j < 3; j++ {
	// 		a[i][j] = nextInt()
	// 	}
	// }

	n := nextInt()

	var out int
	var ans int

	for i := 1; i <= n; i++ {
		if i%2 == 0 {
			cnt := 0
			for j := i; j%2 == 0; {
				j = j / 2
				cnt++
			}
			if cnt > out {
				out = cnt
				ans = i
			}
		}
	}

	fmt.Println(ans)

}
//  [go]
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)

	res, cnt := 0, 0
	for i := 1; i <= n; i++ {
		t, c := i, 0
		for t % 2 == 0 {
			t /= 2
			c += 1
		}
		if cnt < c {
			res = i
			cnt = c
		}
	}

	fmt.Println(res)
}
//  [go]
package main

import (
  "fmt"
)
func main() {
  var N int
  fmt.Scan(&N)

  ans := 1
  for ans * 2 <= N {
   ans *= 2
   fmt.Println(ans)
  }
  fmt.Println(ans)
}
//  [ruby]
N=gets.to_i

ret = 1
while ret <= N
    ret *= 2
end

puts ret/2
//  [ruby]
def mydiv(n, cnt=0)
    n % 2 == 0 ? mydiv(n.div(2), cnt.next) : cnt
end
N = gets.to_i
max_cnt = 0
max_n = 1
1.upto(N) do |n|
    cnt = mydiv(n)
    if max_cnt < cnt
        max_cnt = cnt 
        max_n = n
    end
end
puts max_n
//  [ruby]
n = gets.to_i
puts 2 ** Math::log2(n).to_i
//  [ruby]
def create_array(n,ary)
  return ary[n] = 1 if n == 0
  ary[n] = create_array(n-1,ary)*2
  ary[n]
end
ary = []
create_array(7,ary)
ary.each_cons(2) {|a,b| puts a if (a...b).include?(n)}
//  [ruby]
n = gets.chomp.to_i

if n % 2 == 0
  print n
else
  print n - 1
end
//  [ruby]
n = gets.to_i
max = 0
maxCnt = 0

(1..n).each do |val|
    tmpCnt = 0
    if val.odd?
        next
    else
        calcVal = val
        while calcVal.even?
            calcVal /= 2
            tmpCnt += 1
        end
    end
    
    if tmpCnt > maxCnt
        maxCnt = tmpCnt
        max = val
    end
end

puts max
//  [rust]
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);

    let mut m = 0;
    let mut m_x = 0;

    for x in 1..N + 1 {
        let mut k = 0;
        let mut y = x;
        while y >= 2 && y % 2 == 0 {
            y /= 2;
            k += 1;
        }
        if m <= k {
            m = k;
            m_x = x;
        }
    }

    println!("{}", m_x)
}
//  [rust]
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    println!(
        "{}",
        if 2 > n {
            1
        } else if 4 > n {
            2
        } else if 8 > n {
            4
        } else if 16 > n {
            8
        } else if 32 > n {
            16
        } else if 64 > n {
            32
        } else {
            64
        }
    )
}
//  [rust]
use std::io::stdin;

fn main() {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    let upper = buf.trim().parse::<i32>().unwrap();

    let mut pow2 = 1;
    if upper == 1{
        println!("1");
    } else {
        while pow2 <= upper {
            pow2 *= 2;
        }
        println!("{}", pow2 / 2);
    }
}
//  [rust]
fn main() {
    let n: usize = read();
    let mut ans = 0;
    let mut max = 0;
    for i in 1..n+1 {
        let mut s = 0;
        for x in 1..7 {
            if 2_i32.pow(x) <= (i as i32) {
                s = x;
            } else {
                break
            }
        }
        if max < s {
            max = s;
            ans = i;
        }
    }
    println!("{}", ans);
}

use std::io::stdin;
use std::io::Read;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let cin = stdin();
    let cin = cin.lock();
    let token: String = cin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
//  [rust]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
 
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
 
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
 
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
 
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
 
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
 
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
 
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
 
 
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn xx(i:usize) -> i32 {
    if i % 2 == 0 && i != 0 {
        return xx(i / 2) + 1;
    } else {
        return 0;        
    }
}
fn main() {
    /*     input! {
        n: usize,
        mut plan: [(i32, i32, i32); n],  // Vec<(i32, i32, i32)>
    }
 */
    input! {
        n:usize,
    }
    let mut ans = 0;
    let mut cnt = 0;
    for i in (0..n+1).filter(|x|x % 2 == 0){
        let cur_cnt = xx(i);
        if cnt < cur_cnt {
            ans = i;
            cnt = cur_cnt;
        }
    }
    println!("{}",ans);
}
//  [rust]
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut ans: usize = 1;
    if n == 0 {
        println!("1");
        return;
    }
    while ans < n {
        ans *= 2;
    }
    println!("{}", ans / 2);
}
//  [swift]
let s = Int(readLine()!)!
var a = 1
while s >= a {
    a *= 2
}

print(a/2)
//  [swift]
#if os(OSX) || os(iOS)
    import Darwin
#elseif os(Linux)
    import Glibc
#endif
print(1 << Int(floor(log2(Double(readLine()!)!))))
//  [swift]
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
var ans = 0
if N < 2 {
    ans = 1
} else if N < 4 {
    ans = 2
} else if N < 8 {
    ans = 4
} else if N < 16 {
    ans = 8
} else if N < 32 {
    ans = 16
} else if N < 64 {
    ans = 32
} else {
    ans = 64
}
print(ans)
//  [swift]
import Foundation
var s = [Int]()
for i in 1 ..< 10 {
    var a = Int(pow(2, Double(i)))
    s.append(a)
}

let a = Int(readLine()!)!

var num = 0
while a >= s[num] {
    num += 1
}
print(s[num-1])
//  [swift]
let s = 90
var a = 1
while s >= a {
    a *= 2
}

println(a/2)
//  [typescript]
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const ceil=(a)=>{return Math.ceil(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};const gojo=(a:number,b:number):number=>{if(a%b===0)return b;return gojo(b,a%b)};const deduplicate=(a:number[])=>{return Array.from(new Set(a))};
const main=()=>{
  let n=tn(),index=0,ma=0
  for(let i=1;i<=n;i++){
    let m=i,c=0
    while(m%2==0&&m!=0){
      m/=2
      c++
    }
    if(ma<=c){
      index=i
      ma=c
    }
  }
  to(index)
}
main()
//  [typescript]
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let N =Number(xs[0]);
   let ans = 0;
   for(let i=1; i<=N; i++){
   	 ans = Math.pow(2,i);  
     if(N==1){
     ans = 1;
     break;
     }else if(ans>N){
        ans =Math.pow(2,i-1)
        break;
     }
   }
   console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));
//  [typescript]
const log = console.log;

const findFirstSet = (bits: number): number | null => {
  for (let i = 0; i < 64; i += 1) {
    if ((bits & 1) === 1) return i;
    bits >>>= 1;
  }

  return null;
};

// ----

function Main(input: string): void {
  const n = parseInt(input);

  let maxDivisionCount = 0;
  let answer = 1;

  for (let i = 1; i <= n; i += 1) {
    const divisionCount = findFirstSet(i);

    if (!divisionCount || maxDivisionCount > divisionCount) continue;

    maxDivisionCount = divisionCount;
    answer = i;
  }

  log(answer);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [typescript]
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let N =Number(xs[0]);
   let ans = 0;
   for(let i=1; i<=N; i++){
   	 ans = Math.pow(2,0);  
     if(N==1){
     ans = 1;
     break;
     }else if(ans>N){
        ans =Math.pow(2,i-1)
        break;
     }
   }
   console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));
//  [typescript]
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let N =Number(xs[0]);
   let ans = 0;
   for(let i=1; i<N; i++){
   	 ans = Math.pow(2,i);
     if(ans>N){
        ans =Math.pow(2,i-1)
        break;
     }
   }
   console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));
//  [typescript]
"use strict";
const Main = (input) =>{
   let xs = input.trim().split(' ').map(v=>parseInt(v,10));
   let N =xs[0];
   let ans = 0;
   for(let i=1; i<7; i++){
   	 ans = Math.pow(2,i);
     if(ans>N){
        ans =Math.pow(2,i-1)
        return;
     }
   }
   console.log(ans);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));
//  [python]
import sys
from bisect import bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N, *A = map(int, read().split())

    dp = [A[-1]]
    for a in reversed(A[:-1]):
        if a >= dp[-1]:
            dp.append(a)
        else:
            dp[bisect_right(dp, a)] = a

    print(len(dp))
    return


if __name__ == '__main__':
    main()
//  [python]
def main():
    import sys
    import bisect

    read = sys.stdin.buffer.read
    bisect_right = bisect.bisect_right

    N, *A = map(int, read().split())

    dp = [A[-1]]
    for a in reversed(A[:-1]):
        if a >= dp[-1]:
            dp.append(a)
        else:
            dp[bisect_right(dp, a)] = a

    print(len(dp))
    return


if __name__ == '__main__':
    main()
//  [python]
import sys
from bisect import bisect_right

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N, *A = map(int, read().split())

    vec = [A[-1]]
    for a in reversed(A[:-1]):
        if a >= vec[-1]:
            vec.append(a)
        else:
            vec[bisect_right(vec, a)] = a

    print(len(vec))
    return


if __name__ == '__main__':
    main()
//  [python]
import bisect
def get_LIS(seq):
    LIS = [seq[0]]
    for i in range(1,len(seq)):
        if seq[i] >= LIS[-1]:
            LIS.append(seq[i])
        else:
            LIS[bisect.bisect_left(LIS, seq[i])] = seq[i]

    print(len(LIS))


N = int(input())
A = [int(input()) for _ in range(N)]
A = A[::-1]
get_LIS(A)
//  [python]
from bisect import *

def LIS(N, A):
    L = [0 for i in range(N+1)]
    L[0] = A[0]
    length = 1
    for i in range(1, N):
        if L[length-1] <= A[i]:
            # 最長を更新できる場合
            L[length] = A[i]
            length += 1
        else:
            # L にA[i]が入る場所を二分探索
            index = bisect_left(L, A[i], 0, length)
            L[index] = A[i]
    return length


N = int(input())
A = [int(input()) for _ in range(N)]
A = A[::-1]
print(LIS(N, A))
//  [python]
import sys
from bisect import bisect_left

def bisect_left_reverse(a, x):
    '''
    reverseにソートされたlist aに対してxを挿入できるidxを返す。
    xが存在する場合には一番左側のidxとなる。
    '''
    if a[0] <= x:
        return 0
    if x < a[-1]:
        return len(a)
    # 二分探索
    ok = len(a) - 1
    ng = 0
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if a[mid] <= x:
            ok = mid
        else:
            ng = mid
    return ok

input = sys.stdin.readline
N = int(input())
A = []
for _ in range(N):
	A.append(int(input()))

multi_lis = []
for a_i in A:
    if not multi_lis:
        multi_lis.append(a_i)
        continue

    if a_i <= multi_lis[-1]:
        multi_lis.append(a_i)
    else:
        p = bisect_left_reverse(multi_lis, a_i)
        multi_lis[p] = a_i 

print(len(multi_lis))
//  [cpp]
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint();
	int A[100001];

	int k = N;
	A[N] = -1;

	rep(i, N) {
		int a = getint();
		auto itr = lower_bound(A + k, A + N + 1, a) - 1;
		*itr = a;
		if (itr == A + k) {
			k--;
			A[k] = -1;
		}
	}

	printf("%d", N - k);

	Would you please return 0;
}
//  [cpp]
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int read() {
    static char s[1 << 16];
    static int i, n;
    int r = 0;
    for (;;) {
        if (i == n) {
            cin.read(s, sizeof(s));
            i = 0;
            n = (int)cin.gcount();
            if (n == 0) break;
        }
        unsigned int c = s[i++] - '0';
        if (c < 10) {
            r *= 10;
            r += c;
        } else {
            break;
        }
    }
    return r;
}

int main() {
    int n = read();

    vector<int> m;
    m.reserve(n);

    for (int i = 0; i < n; i++) {
        int a = read();

        auto it = upper_bound(m.begin(), m.end(), a, greater<>());
        if (it == m.end()) m.push_back(a); else *it = a;
    }

    cout << m.size() << endl;

    return 0;
}
//  [cpp]
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int N = getint();
	int A[100000];
	rep(i, N) A[i] = -1;

	int k = N - 1;

	rep(i, N) {
		int a = getint();
		auto itr = lower_bound(A + k, A + N, a) - 1;
		*itr = a;
		if (itr == A + k) k--;
	}

	co(N - k - 1);

	Would you please return 0;
}
//  [cpp]
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<long long> a(n);
    for(int i=0;i<n;++i) cin>>a[i];
    reverse(a.begin(),a.end());
    vector<long long> dp(n,1);

    for(int i=0;i<n;++i){
        for(int j=0;j<i;++j){
            if(a[i]>=a[j]) dp[i]=max(dp[i],dp[j]+1);
        }
    }

    cout<<*max_element(dp.begin(),dp.end())<<endl;
}
//  [cpp]
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

// ei1333
struct UnionFind {
    vector<int> data;

    UnionFind(int sz) {
        data.assign(sz, -1);
    }

    bool unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return (false);
        if (data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k) {
        if (data[k] < 0) return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k) {
        return (-data[find(k)]);
    }
};

const int INF = 1e9 + 7;
// ACL contest 1 のA問題

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    repeat(i, N) cin >> A[i];
    UnionFind uf(N);
    stack<int> stk;
    repeat(i, N) {
        int minA = A[i];
        int minID = i;
        while (!stk.empty()) {
            int id = stk.top();
            if (A[id] >= minA) break;
            // A[id] < minA
            uf.unite(id, i);
            minA = A[id];
            minID = id;
            stk.pop();
        }
        stk.push(minID);
    }
    vector<bool> used(N);
    int res = 0;
    repeat(i, N) {
        int par = uf.find(i);
        if (!used[par]) {
            ++res;
            used[par] = true;
        }
    }
    cout << res << endl;
    return 0;
}
//  [cpp]
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < int(n);i++)


int main() {
	int n;
	cin >> n;
	vector<int> v(n);
	rep(i,n) cin >> v[i];
	int ans = 1;
	int now = v[0];
	for (int i = 1; i < n;i++){
		if (v[i] <= now){
			ans++;
			now = v[i];
			//cout << "now is " << now << endl;
		}
	}
	cout << ans << endl;
		
	return 0;
}
//  [c]
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

void rsortr_u32(void *base, const int count){
	uint32_t *a=base;
	uint32_t *b=malloc(count*sizeof(uint32_t));
	int c[0x100];
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(0<<3))&0xFF]++; } for(int i=0xFE; i>=0; i--) c[i]+=c[i+1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(0<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(1<<3))&0xFF]++; } for(int i=0xFE; i>=0; i--) c[i]+=c[i+1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(1<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(2<<3))&0xFF]++; } for(int i=0xFE; i>=0; i--) c[i]+=c[i+1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(2<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(3<<3))&0xFF]++; } for(int i=0xFE; i>=0; i--) c[i]+=c[i+1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(3<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	free(b);
}
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }

int d[100000];

int bs(int k, int l, int r){
	while(l<=r){
		int m=(l+r)/2;
		if(d[m]<k) r=m-1; else l=m+1;
	}
	return l;
}

int main(void){
	int n=nextint();
	for(int i=0; i<n; i++){
		d[i]=-1;
		int a=nextint();
		int j=bs(a,0,i-1);
		d[j]=a;
	}
	int ans=bs(0,0,n-1);
	printf("%d\n", ans);
}
//  [c]
#include <stdio.h>

int main(void) {

  long n;
  scanf("%ld", &n);
  long a[n];
  for (long i = 0; i < n; i++) {
    scanf("%ld", &a[i]);
  }
  long list[n];
  list[0] = a[0];
  long list_size = 1;
  long start,end,center;
  for (long i = 1; i < n; i++) {
    if (a[i] <= list[list_size-1]) {
      list[list_size] = a[i];
      list_size++;
    } else {
      if (a[i] > list[0]) {
        list[0] = a[i];
        continue;
      }
      start = 0;
      end = list_size-1;
      while (start+1 != end) {
        center = (start+end)/2;
        if (list[center] >= a[i]) {
          start = center;
        } else {
          end = center;
        }
      }
      list[end] = a[i];
    }
  }
  printf("%ld\n", list_size);

  return 0;
}
//  [c]
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>

typedef int32_t i32;

#define ALLOC(size,type) ((type*)calloc((size),sizeof(type)))

void run (void) {
  i32 n;
  scanf ("%" SCNi32, &n);
  i32 *dp = ALLOC (n + 1, i32);
  dp[0] = 1000000000 + 1;
  i32 len = 0;
  for (i32 i = 0; i < n; ++i) {
    i32 a;
    scanf ("%" SCNi32, &a);
    if (dp[len] >= a) {
      dp[++len] = a;
      continue;
    }
    i32 l = 0;
    i32 r = len;
    while (r - l > 1) {
      i32 m = (l + r) / 2;
      if (dp[m] >= a) {
        l = m;
      } else {
        r = m;
      }
    }
    dp[r] = a;
  }
  printf ("%" PRIi32 "\n", len);
}

int main (void) {
  run();
  return 0;
}
//  [c]
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int num[100009]={0},a[100009]={0},f=0;
int main()
{
    int n,i,mi;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        int n1;
        scanf("%d",&n1);
        num[i]=n1;
    }
    a[1]=num[1];
    f++;
    mi=a[1];
    for(i=2;i<=n;i++){
        if(num[i]<=mi){
            mi=num[i];
            a[++f]=num[i];
        }
        else{
                for(int j=1;j<=f;j++){
                    if(a[j]<num[i]){
                        a[j]=num[i];
                        if(j==f)
                            mi=num[i];
                            break;
                    }
                }
        }
        //printf("%d  %d\n",mi,f);

    }
    printf("%d\n",f);

    return 0;
}
//  [c]
#include <stdio.h>
#include<stdlib.h>
int min(int a, int b){return a < b ? a : b;}
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void){
    int n;
    int list[100000], a[100000];
    int b[100000];//既に配列を使ったかどうかを記録する

    int i, j, k;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }


    b[0] = a[n-1];
    int cnt = 1;
    int c_list[100000];
    int b_min, b_min_i;
    int mid;
    for(i = n - 2; i >= 0; i--){
        int tmp = 0;//塗る事の出来る色をカウント
        //a[i]を何かの色で塗りたい
        //bはソートされているため，b[j] > a[i]を満たす最小のb[j]をとるjの値を二分探索で求める
        //ない場合はflag=0
        if(b[cnt - 1] <= a[i]){
            b[cnt] = a[i];
            cnt++;
        }else if(b[0] > a[i]){
            j = 0;
            b[j] = a[i];
        }else{
            int r = cnt;
            int l = 0;
            while(r - l != 1){
                mid = (r + l) / 2;
                if(b[mid] < a[i]){
                    l = mid;
                }else if(b[mid] > a[i]){
                    r = mid;
                }else{
                    l = mid;
                }
            }
            j = r;
            b[j] = a[i];
        }

        qsort(b, cnt, sizeof(int), compare_int);
    }

    printf("%d\n", cnt);

    return 0;    
}
//  [c]
#include <stdio.h>
#include<stdlib.h>
int min(int a, int b){return a < b ? a : b;}
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void){
    int n;
    int list[100000], a[100000];
    int b[100000];//既に配列を使ったかどうかを記録する

    int i, j, k;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }


    b[0] = a[n-1];
    int cnt = 1;
    int c_list[100000];
    int b_min, b_min_i;
    for(i = n - 2; i >= 0; i--){
        int tmp = 0;//塗る事の出来る色をカウント
        //a[i]を何かの色で塗りたい
        for(j = 0; j < cnt; j++){
            if(b[j] > a[i]){
                tmp++;
                if(tmp == 1){
                    b_min = b[i];
                    b_min_i = i;
                }else{
                    if(b_min > b[i]){
                        b_min = b[i];
                        b_min_i = i;
                    }
                }
            }
        }

        //今ある色で塗れない場合
        if(tmp == 0){
            b[cnt] = a[i];
            cnt++;
        }else{//塗れる場合
            b[b_min_i] = a[i];
        }
        //qsort(b, cnt, sizeof(int), compare_int);
    }

    printf("%d\n", cnt);

    return 0;    
}
//  [javascript]
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
function upper_bound(d,a,b,e){for(var c;1<b-a;)d[c=0|(a+b)/2]<=e?a=c:b=c;return d[a]<=e?b:a};

console.log(main());
function main(){
  var n = o.a();
  var a = o.r(n);
  var ans = [1];
  for(var i = 0; i < n; i++){
    var t = -a[i];
    var l = upper_bound(ans,0,ans.length,t);
    ans[l] = t;
  }
  return ans.length;
}
//  [javascript]
//↓見なくていいよ！ここから--------------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//↑見なくていいよ！ここまで--------------------------------------------------
function Main(){
	var N = nextInt();
	var list = [];
	for(var i = 0; i < N; i++){
		var a = nextInt();
		if(i == 0){
			list.push(a);
			continue;
		}
		var index = binarySearch(list,a);
		if(index == list.length){
			list.push(a);
		}else{
			list[index] = a
		}
		//myerr(list);
	}
	myout(list.length);
}
function binarySearch(list,search){
  //listはあらかじめ昇順ソート済みとする。右側が有効エリア、左側が無効エリアと仮定し、
  //searchによって返す要素(インデックス)は ok:有効な部分の最小値、ng:無効な部分の最大値
  var ng = -1;
  var ok = list.length;
  var center;
  while(Math.abs(ok - ng) > 1){
    center = Math.floor((ok + ng) / 2);
    if(list[center] < search){
       ok = center;
    }else{
       ng = center;
    }
  }
  return ok;
  //return ng;
}
//  [javascript]
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0]-0;
  var colors=[];
  var temp;
  var min,max,mid;
  for(var i=1;i<input.length;i++){
    temp=input[i]-0;
    if(colors.length===0){
      colors.push(temp);
      continue;
    }
    if(temp<=colors[0]){
      colors.unshift(temp);
      continue;
    }
    if(temp>colors[colors.length-1]){
      colors[colors.length-1]=temp;
      continue;
    }
    min=0;
    max=colors.length-1;
    while(max-min>1){
      mid=Math.floor((max+min)/2);
      if(colors[mid]<=temp){
        max=mid;
      }else{
        min=mid;
      }
    }
    colors[min]=temp;
  }
  console.log(colors.length);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
//  [javascript]
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  myerr("-----start-----");
  var start = new Date();
  Main();
  var end = new Date() - start;
  myerr("----- end -----");
  myerr("time : " + (end) + "ms");
});
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException これ以上ないよ";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す 1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
  var list = new Array(N);
  var max = 0;
  var count = 1;
  for(var i = 0; i < N; i++){
    list[i] = nextInt();
  }
  for(var i = N - 1; i > 0; i--){
    if(list[i - 1] >= list[i]){
      if(max <= list[i - 1]){
        max = list[i - 1];
        count++;
      }
    }
  }
  myout(count);
}