akhauriyash/Code-Regression huggingface dataset:
struct Read<R: std::io::BufRead> {
    stdin: R,
    v: Vec<String>,
    i: usize,
}
impl<R: std::io::BufRead> Read<R> {
    pub fn new(stdin: R) -> Self {
        Read {
            stdin: stdin,
            v: Vec::new(),
            i: 0,
        }
    }
    #[allow(dead_code)]
    pub fn read_one_line(&mut self) -> String {
        self.i = 0;
        self.v.clear();
        let mut buf = String::new();
        self.stdin.read_line(&mut buf).unwrap();
        buf.trim().to_owned()
    }
    pub fn read_line(&mut self) {
        self.i = 0;
        self.v.clear();
        let mut buf = String::new();
        self.stdin.read_line(&mut buf).unwrap();
        let buf = buf.trim().to_owned();
        let mut ws = buf.split_whitespace();
        loop {
            let x = ws.next();
            if x.is_none() {
                break;
            }
            let x = x.unwrap().to_owned();
            self.v.push(x);
        }
    }
    #[allow(dead_code)]
    pub fn read_a<T: std::str::FromStr>(&mut self) -> T {
        if self.i == self.v.len() {
            self.read_line();
        }
        let elem = &self.v[self.i];
        self.i += 1;
        elem.parse().unwrap_or_else(|_| panic!())
    }
}

use std::cmp;
use std::collections::HashMap;
fn main() {
    let stdin = std::io::stdin();
    let stdin = std::io::BufReader::new(stdin.lock());
    let mut r = Read::new(stdin);

    let n:usize = r.read_a();
    let mut a:Vec<u64> = Vec::new();
    for i in 0..n {
        a.push(r.read_a());
    }

    a.sort();
    a.reverse();
    let mut ans = 0;
    let mut cnt = 0;

    if n == 2 {
        println!("{}", a[0]);
        return;
    }
    for i in 1..n {
        ans += a[i];
        cnt += 1;
        if cnt >= n - 2 {
            break;
        }
        ans += a[i];
        cnt += 1;
        if cnt >= n - 2 {
            break;
        }
    }

    ans += a[0];

    println!("{}", ans);

}


Measured memory_bytes: 17304
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int H, W;
const int Hmax = 50;
string S[Hmax];

int main(){
	cin >> H >> W;
	for(int i=0; i<H; i++) cin >> S[i];

	for(int i=0; i<H; i++){
		for(int j=0; j<W; j++){
			if(S[i][j]=='.') continue;
			int dx[] = {1, -1, 0, 0};
			int dy[] = {0, 0, 1, -1};
			bool ok = false;
			for(int k=0; k<4; k++){
				int nx = i+dx[k];
				int ny = j+dy[k];
				if(0<=nx&&nx<H&&0<=ny&&ny<W&&S[nx][ny]=='#') ok = true;
			}
			if(!ok){
				cout << "No" << endl;
				return 0;
			}
		}
	}

	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main() {
    int n, d, i, j, k, count;
    scanf("%d %d", &n, &d);

    double x[n][d];

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

    double dist;

    count = 0;

    for(i=0; i<n; i++) {
        for(j=i+1; j<n; j++) {
            dist = 0;
            for(k=0; k<d; k++) {
                dist += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
            }
            if(ceil(sqrt(dist))==floor(sqrt(dist))) {
                count += 1;
            }
        }
    }

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

    return 0;

}

Measured memory_bytes: 128
#include<bits/stdc++.h>

using namespace std;

#define ll long long int
#define fo(i,b,n) for(int i=(b); i<(n) ; i++)
#define xx first
#define yy second
#define pb push_back
#define sz(n) int(n.size())
#define pii pair
#define MP make_pair

#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define readl(x) scanf("%lld",&x)
#define readl2(x,y) scanf("%lld%lld",&x,&y)
#define readd(x) scanf("%lf",&x)
#define readd2 scanf("%lf%lf",&x,&y)

#define pr(n) printf("%d",n)
#define prn(n) printf("%d\n",n)
#define prl(n) printf("%lld",n)
#define prln(n) printf("%lld\n",n)
#define prd(x) printf("%lf",x)
#define prdn(x) printf("%lf\n",x)

#define TC(n) printf("Case %d: ",n)

int ar[100005];
int main()
{
    int n,a,b;
    read(n);
    read2(a,b);
    int cnt=0;
    fo(i,0,n){
        read(ar[i]);
        if(ar[i]>=a && ar[i]<b)continue;
        else cnt++;
    }
    prn(cnt);
    return 0;
}















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//char型から数値型に変換する関数（z.at(i)などに使用）
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int main() {
  string s;
  cin>>s;
  bool t=false;
  for(int i=0;i<s.size()-1;i++){
   if(s.at(i)=='A'&&s.at(i+1)=='C'){
     t=true;
   }
  }
  if(t){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int H, W, max_ = 0;

	cin >> H >> W;

	vector<vector<int> > c(H, vector<int>(W));

	vector<vector<int> > dp(H, vector<int>(W, 0));

	for (int i = 0; i < H; i++)
	{
		for (int j = 0; j < W; j++)
		{
			cin >> c[i][j];

			if (c[i][j] == 0)
			{
				if (i == 0 || j == 0)
				{
					dp[i][j] = 1;
				}

				max_ = 1;
			}
		}
	}

	for (int i = 1; i < H; i++)
	{
		for (int j = 1; j < W; j++)
		{
			if (c[i][j] == 0)
			{
				dp[i][j] = min({ dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1] }) + 1;

				max_ = max(dp[i][j], max_);
			}
		}
	}

	cout << max_ * max_ << endl;

	return 0;
}

Measured memory_bytes: 18212
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
#define lwbt(x) ((x)&(-(x)))
int l,m,n=0;
struct ee{
    int u;
    int v;
    int w;
}e[65];
int et=0;
inline void add(const int &u,const int &v,const int &w){
    e[++et]=(ee){u,v,w};
}
void init(){
    scanf("%d",&l);
    int nw=l;
    while(nw){
        ++n;
        nw>>=1;
    }
    for(int i=1;i<n;++i){
        add(i,i+1,0);
        add(i,i+1,1<<(i-1));
    }
    nw=1<<(n-1);
    int x;
    while(lwbt(l)!=l){
        x=lwbt(l);
        add(log2(x)+1,n,nw);
        nw+=x;
        l-=x;
    }
    printf("%d %d\n",n,et);
    for(int i=1;i<=et;++i){
        printf("%d %d %d\n",e[i].u,e[i].v,e[i].w);
    }
    
}
int main(){
    init();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int deg1, deg10, deg100, deg1000;
  
  cin >> N;
  
  deg1000 = (N / 1000);
  deg100 = (N / 100) - (deg1000 * 10);
  deg10 = (N / 10) - (deg1000 * 100) - (deg100 * 10);
  deg1 = N - (deg1000 * 1000) - (deg100 * 100) - (deg10 * 10);
  
  if (((deg1000 == deg100) && (deg100 == deg10)) || ((deg100 == deg10) && (deg10 == deg1))) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
require 'set'

n,m = gets.split.map(&:to_i)
hash = Hash.new(0)
m.times do
  a,b = gets.split.map(&:to_i)
  hash[a]=[hash[a],b].max
end
1.upto(n) do |i|
  next if hash[i]==0
  next if i==hash[i]
  max =hash[i]
  num =i
  (i+1).upto(hash[i]) do |j|
    if  hash[j]>max && (hash[hash[j]]==0 || hash[j]==n)
      max = hash[j]
      num=j
    end
  end
  (i+1).upto(hash[i]) do |j|
    unless j==num
      hash.delete(j)
    end
  end
end
arr =Set.new
hash.each do |key,value|
  key.upto(value) do |j|
    arr << j
  end
end
flag = true
1.upto(n) do |i|
  unless arr.include?(i)
    flag = false
    break
  end
end
puts flag ? hash.size : "Impossible"

Measured memory_bytes: 12000
#include <bits/stdc++.h>

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
			cin.tie(0);							 \
			cout.tie(0);
#define PI 3.141592654

using namespace std;

using ll = long long;
const int MOD = 1e9 + 7;
const ll INF = 1e18 + 9;

ll powmod(ll base, ll exp, const ll MOD) { ll ans = 1; while (exp) { if (exp & 1)	ans = (ans * base) % MOD; base = (base * base) % MOD; exp >>= 1; } return ans; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
void add(ll& x, ll v) { x = (x + v) % MOD; if (x < 0) x += MOD; }
//ll f[500005];
//ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }

void test_case() {

}

const int mxN = 1e5 + 1;


int main() {
	fastio;
	int n;
	cin >> n;
	vector<ll> a(n + 1), prefix(n + 1), suffix(n + 2);
	ll sumxor = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i];
		prefix[i] = prefix[i - 1] ^ a[i];
		sumxor ^= a[i];
	}


	for (int i = 1; i <= n; ++i)
		cout << (sumxor ^ a[i]) << " ";

	
	return 0;
}

Measured memory_bytes: 7928
#include <bits/stdc++.h>
using namespace std;

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

void solve() {
    int n,m;
    cin >> n >> m;
    vector<int> d;
    FOR(i,0,m) {
        int x;
        cin >> x;
        d.push_back(x);
    }
    std::sort(d.begin(),d.end());
    vector<int> dn;
    FOR(i,0,m -1) dn.push_back(d[i+1] - d[i]);
    std::sort(dn.begin(),dn.end());
    int ans = 0;
    FOR(i,0,m - n ) ans += dn[i];
    cout << ans <<endl;
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 1400
#include<iostream>

using namespace std;

int getValue(int x){
    if ( x == 4 ) return 5;
    return (x < 4) ? x : x+2;
}

void convert( int n ){
    if ( n == 0 ) return;
    convert( n/8 );
    cout << getValue(n%8);
}

main(){
    int n;
    while( cin >> n && n ) { convert(n); cout << endl; }
}

Measured memory_bytes: 864
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define s(x, n) memset(x, n, sizeof(x));
#define pb(x) push_back(x)
#define NIL -1
#define MAXN 11

void solve()
{
    int n;
    cin >> n;
    while (n--)
    {
        cout << "ACL";
    }
}
int main()
{
#ifdef WIN32
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

#ifndef WIN32
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#endif
    int t;
    t = 1;
    /// cin >> t;
    for (int I = 1; I <= t; I++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
using namespace std;
int H,W,x[1000][1000],c[1000][1000];
int main(){
	cin>>H>>W;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			char f;cin>>f;
			if(f=='c')x[i][j]=1;
			c[i][j]=-1;
		}
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			for(int k=j;k>=0;k--){
				if(x[i][k]==1){c[i][j]=j-k;break;}
			}
		}
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			if(j>0)cout<<' ';
			cout<<c[i][j];
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 3856
def binary_search(array, value, begin, end):
    if begin >= end:
        return None
    else:
        next_index = begin + (end - begin) // 2
        if array[next_index] == value:
            return next_index
        elif array[next_index] < value:
            return binary_search(array, value, next_index + 1, end)
        else:
            return binary_search(array, value, begin, next_index)

def main():
    n = int(input())
    S = [int(i) for i in input().split()]
    q = int(input())
    T = [int(i) for i in input().split()]

    count = 0
    for t in T:
        if binary_search(S, t, 0, len(S)) != None:
            count += 1

    print(count)

if __name__ == '__main__':
    main()

Measured memory_bytes: 18972
#include <bits/stdc++.h>
using namespace std;

int X,Y;

const int MAX = 1000000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];

void init_binomial_coefficient() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long binomial_coefficient(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  cin >> X >> Y;
  if ((X+Y) % 3 || X <=0 || Y <=0) {
    cout << 0 << endl;
    return 0;
  }

  int a = (2*Y - X) / 3;
  int b = (2*X - Y) / 3;
  init_binomial_coefficient();

  cout << binomial_coefficient(a+b, b) << endl;
  return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;

int gcd(int a, int b) {
  if (a < b) swap(a,b);
  while(1) {
    if (b == 0) return a;
    int t = a;
    a = b;
    b = t%b;
  }
}

int main() {
  int N;
  cin >> N;
  vector<int> hp(N);
  for (int i = 0; i < N; i++) cin >> hp[i];
  int g = gcd(hp[0],hp[1]);
  for (int i = 2; i < N; i++) g = gcd(g,hp[i]);
  cout << g << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using Map = map<ll,ll>;
using T = tuple<ll,ll,ll>;
using vvl = vector<vector<ll>>;
#define all(v) v.begin(), v.end()
#define print(v) cout<<v<<endl
#define first(v) get<0>(v)
#define second(v) get<1>(v)
#define third(v) get<2>(v)
template <typename T> bool chmax(T &a, T &b){if (a<b){a=b;return 1;}return 0;}
template <typename T> bool chmin(T &a, T &b){if (a>b){a=b;return 1;}return 0;}
const ll INF=1LL<<60;
const ll MOD=1000000007;


int main(){
    ll L;
    cin >> L;
    L--;
    //T(from,to,cost)
    vector<T> ans(0);
    ll now=1;
    while(L>0){
        if(L%2){
            ans.emplace_back(T(now,now+1,0));
            ans.emplace_back(T(now,now+1,L/2+1));
            L/=2;
        }
        else{
            ans.emplace_back(T(now,now+1,0));
            ans.emplace_back(T(now,now+1,L/2));
            ans.emplace_back(T(now,INF,L));
            L/=2;L--;
        }
        now++;
    }
    ll d=ans.size();
    cout<<now<<" "<<d<<endl;
    for(ll i=0;i<d;i++){
        if(second(ans[i])!=INF){
            cout<<first(ans[i])<<" "<<second(ans[i])<<" "<<third(ans[i])<<endl;
        }
        else cout<<first(ans[i])<<" "<<now<<" "<<third(ans[i])<<endl;
    ;}


    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
string s;
int main(void){
    cin>>s;
    for(int i=0;i<s.size()-1;i++){
        if(s[i]==s[i+1]){
            cout<<i+1<<" "<<i+2<<endl;
            return 0;
        }else if(i<s.size()-2&&s[i]==s[i+2]){
            cout<<i+1<<" "<<i+3<<endl;
            return 0;
        }
    }
    cout<<-1<<" "<<-1<<endl;
    
}


Measured memory_bytes: 512
K,N = map(int, input().split())
A = list(map(int, input().split()))
B = [0]*N

#最大の距離を求める

for i in range(N):
  B[i] = min((A[i]-A[(i+1)%N])%K,(-A[i]+A[(i+1)%N])%K)
print(K-max(B))

Measured memory_bytes: 26444
#include <bits/stdc++.h>
using namespace std;

int main()
{
	int N;
	string S;
	cin >> N >> S;
	vector<int> B(N+1, 0);
	vector<int> W(N+1, 0);

	int black = 0, red = 0;
	int x = N - 1; int y = 0;
	for(int i = 0; i < N-1; i++){
            for(int j = x; j >= 0;j--){
        if(S[j] == 'R' || !j){
            x = j;
            break;
        }
	}
		if(S[i] == 'W' && S[x] == 'R' && x > i){
			swap(S[i], S[x]);
			x --;
			y ++;
		}
	}
	for (int i = 0; i < N; i++) {
        if (S[i] == 'W') {
			black++;
		}
		B[i + 1] = black;
		if (S[N - i - 1] == 'R') {
			red++;
		}
		W[N - i - 1] = red;
	}

	int ans = 10e8;
	for (int i = 0; i <= N; i++) {
		ans = min(ans, B[i] + W[i]);
	}

	cout << ans + y << endl;
}


Measured memory_bytes: 5212
#include<iostream>
#include <cmath>
using namespace std;
int main()
{
    // Input numbers
    long long a;
    double b;
    cin >> a >> b;

    long long b_100 = round(b*100);

    // Output
    cout << (long long)((a*b_100)/100) << endl;
    return 0;
}


Measured memory_bytes: 3800
#include <iostream>
#include <map>
#include <string>

int main() {
  int N;
  std::cin >> N;
  std::map<std::string, int> results;
  for (int i = 0; i < N; ++i) {
    std::string S;
    std::cin >> S;
    ++results[S];
  }
  for (const std::string result : {"AC", "WA", "TLE", "RE"}) {
    std::cout << result << " x " << results[result] << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3632
INF = 10_000_000
N = gets.to_i
H = gets.split.map(&:to_i)
ans = 0

head = Array.new(N)
ranges = {}

(1 .. 10_000).find do
  head.clear
  ranges.clear
  
  H.each_index do |i|
    if head[i - 1] && H[i] > 0
      head[i] = head[i - 1]
    elsif head[i - 1].nil? && H[i] > 0
      head[i] = i
    end
  end
  
  head.each_with_index do |head, tail|
    ranges[head] = tail if head
  end
  
  ranges.each do |head, tail|
    w = H[head .. tail].min
    (head .. tail).each{|i| H[i] -= w}
    ans += w
  end

  H.all?(&:zero?)
end
puts ans

Measured memory_bytes: 1916
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<(x)<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

template<typename T> inline void CHMAX(T& a, const T b) {if(a<b) a=b;}
template<typename T> inline void CHMIN(T& a, const T b) {if(a>b) a=b;}

constexpr ll MOD=1000000007ll;
// constexpr ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // cout<<setprecision(10)<<fixed;
  ll a, b, k;
  cin>>a>>b>>k;
  if(a<k){
    k-=a;
    a=0;
  }
  else{
    a-=k;
    k=0;
  }
  // DEBUG(b);DEBUG(k);
  b-=k;
  cout<<a<<' '<<max(b, 0ll)<<'\n';
  return 0;
}


Measured memory_bytes: 256
// (c) midandfeed aka asilentvoice
#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define mt make_tuple

// Looping
#define lp(i, n) for(long long i = 0; i < n; i++)
#define rep(i, a, n) for(long long i = a; i < n; i++)
#define dlp(i, n) for(long long i = n; i >= 0; i--)
#define drep(i, n, a) for(long long i = n; i >= a; i--)
	
// Useful variable
#define bft bool found = true
#define bff bool found = false
#define llvmin ll vmin = 1e9
#define llvmax ll vmax = -1e9
#define llans ll ans = 0

// Data structure
#define pii pair<int, int> 			
#define pll pair<long long, long long> 	
#define vi vector<int> 		 		
#define vll vector<long long> 	
#define vpii vector<pii>
#define vpll vector<pll>

// Read Input
#define ssc(x) scanf("%s", &x)
#define isc(x) scanf("%d", &x)
#define llsc(x) scanf("%lld", &x)
#define fsc(x) scanf("%f", &x)

// Output
#define spr(x) printf("%s", x)
#define ipr(x) printf("%d", x)
#define llpr(x) printf("%d", x)
#define fpr(x) printf("%d", x)
#define nl printf("\n")

// Trash macro
#define so using
#define many namespace
#define tubes std;
#define lelah int
#define nubes main()

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;

so many tubes
lelah nubes
{
	string x;
	
	cin >> x;
	
	int ans = 1;
	bool found = false;
	int len = x.size();
	
	lp(i, len-1)
	{
		if ( x[i] == x[i+1] )
		{
			ans++;
		}
		else
		{
			ans = 1;
		}
		
		// cout << ans;
		// nl;
		
		if ( ans == 3 )
		{
			found = true;
		}
	}
	
	if ( found )
	{
		spr("Yes");
	}
	else
	{
		spr("No");
	}
	
	nl;
		
	
	return 0;
}

Measured memory_bytes: 256
//ABC145-D
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

template <int MOD = 1000000007>
struct Mint{
    int x;

    Mint() : x(0) {}
    Mint(int t){
        x = t % MOD;
        if(x < 0) x += MOD;
    }
    
    Mint pow(int n){
        Mint res(1), t(x);
        while(n > 0){
            if(n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        ll a = x, b = MOD, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint & operator += (Mint a){
        x += a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    
    Mint & operator -= (Mint a){
        x += MOD - a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }

    Mint & operator *= (Mint a){
        x = 1LL * x * a.x % MOD;
        return *this;
    }

    Mint & operator /= (Mint a){
        return (*this) *= a.inv();
    }

    Mint operator + (Mint a) const { return Mint(x) += a; }
    Mint operator - (Mint a) const { return Mint(x) -= a; }
    Mint operator * (Mint a) const { return Mint(x) *= a; }
    Mint operator / (Mint a) const { return Mint(x) /= a; }

    Mint operator - () const{ return Mint(-x); }

    bool operator == (const Mint a){ return x == a.x; }
    bool operator != (const Mint a){ return x != a.x; }
    bool operator < (const Mint a){ return x < a.x; }

    friend ostream & operator << (ostream & os, const Mint &a){
        return os << a.x;
    }

    friend istream & operator >> (istream & is, Mint &a){
        int t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

template <typename T>
struct Comb{
    vector<T> fac, fin;

    Comb(int sz) : fac(sz + 1), fin(sz + 1){
        fac[0] = fin[sz] = T(1);
        for(int i = 1; i <= sz; i++){
            fac[i] = fac[i - 1] * T(i);
        }
        fin[sz] /= fac[sz];
        for(int i = sz - 1; i >= 0; i--){
            fin[i] = fin[i + 1] * T(i + 1);
        }
    }

    inline T fact(int k) const { return fac[k]; }
    inline T finv(int k) const { return fin[k]; }

    T P(int n, int k) const {
        if(k < 0 || n < k) return T(0);
        return fac[n] * fin[n - k];
    }

    T C(int n, int k) const {
        if(k < 0 || n < k) return T(0);
        return fac[n] * fin[n - k] * fin[k];
    }

    T H(int n, int k) const {
        if(n < 0 || k < 0) return T(0);
        return k == 0 ? T(1) : C(n + k - 1, k);
    }
};

signed main(){
    ll x,y;
    cin >> x >> y;
    ll sum = x + y;
    if(sum % 3 == 0 && sum / 3 <= x && x <= sum / 3 * 2 && sum / 3 <= y && y <= sum / 3 * 2){
        ll mn = min(x, y);
        Comb<Mint<MOD>> C(1e6);
        cout << C.C(sum / 3, mn - sum / 3) << endl;
    }else{
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 8064
MOD = 10 ** 9 + 7
MAX = 10 ** 6 + 1
fac = [0] * MAX
finv = [0] * MAX
inv = [0] * MAX

def CoMinit():
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

def COM(n, k):
   if n < k:
       return 0
   if n < 0 or k < 0:
       return 0

   return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD

X, Y = map(int, input().split())

if (X + Y) % 3:
    print(0)
    exit()
n = (X + Y) // 3
X -= n
Y -= n
if X < 0 or Y < 0:
    print(0)
    exit()
CoMinit()
ans = COM(X + Y, X)
print(ans)

Measured memory_bytes: 121844
abck = input().split()
abck= [int(x) for x in abck]
a = abck[0]
b = abck[1]
c = abck[2]
k = abck[3]

    


def check(a,b,c,k):
    resutlt = 0
    if a > k:
        result = k
        return result
    else:
        k -=a
        result = a
        if b>k:
            return result 
        else:
            k -= b
            result  -= k
            return result 

print(check(a,b,c,k))



Measured memory_bytes: 9196
// #include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <iterator>
#include <functional>
#include <limits>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <stack>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define trace(x) cerr << #x << ": " << x << " " << endl;
 
typedef int64_t ll;
 
#define endl '\n'
#define int ll
ll mod=1e12;
ll mod1=1e9+5;
 
ll power(ll a,ll b)
{
    if(b==0) return 1;
    else if(b%2==0)
        return power((((a%mod)*(a%mod))%mod),b/2)%mod;
    else return ((a%mod)*(power((((a%mod)*(a%mod))%mod),b/2)%mod))%mod;
}
     
 //using namespace __gnu_pbds;
 //#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
//find_by_order(k)  returns iterator to kth element starting from 0;
//order_of_key(k) returns count of elements strictly smaller than k;
//erase,insert same as normal set
// mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count()); for randomized solution
int ch(int i)
{
    vector<int> v;
    while(i)
    {
        v.push_back(i%10);
        i/=10;
    }
    reverse(v.begin(),v.end());
    for(int i=0;i<v.size()-1;i++)
    {
        if(abs(v[i]-v[i+1])>1)
            return i+1;
    }
    return 0;
}
bool check(int n,int k)
{
    while(n%k==0)
    {
        n/=k;
    }
    if(n%k==1)
        return 1;
    else
        return 0;
}
int32_t main()
{
    IOS

    
    int n;
    cin>>n;
    int ans=0;
    vector<int> v;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            v.push_back(i);
            if(i*i!=n)
                v.push_back(n/i);
        }
    }
    for(auto i:v)
    {
        if(i==1)
            continue;
        if(check(n,i))
            ans++;
    }
    
    n--;
     vector<int> v1;
    for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            v1.push_back(i);
            if(i*i!=n)
                v1.push_back(n/i);
        }
    }
    ans+=(int)v1.size()-1;

    cout<<ans<<endl;

}       

Measured memory_bytes: 384
using System;
class Program {
  static void Main (string[] args) {
    int n;
    n = int.Parse (Console.ReadLine ());
    int[] posto = new int[n];
    int[] b = new int[n];

    string[] input = Console.ReadLine ().Split (' ');

    for (int i = 0; i < n; i++) {
      b[i] = int.Parse (input[i]);
    }

    int cost = 0;
    int pos =0;
    for (int j = 0; j < n; j++) {
      cost += Math.Abs (pos - b[j]);
      pos = b[j];
      posto[j] = pos;
    }
    cost += Math.Abs (pos);

    for (int i = 0; i < n; i++) {
      int sc = cost;
      if (i == n - 1) {
        sc = sc - Math.Abs (posto[i-1] - posto[i]) - Math.Abs (posto[i] - 0)  + Math.Abs (posto[i-1] - 0);
      } else if (i == 0) {
        sc = sc - Math.Abs (0 - posto[i]) - Math.Abs (posto[i] - posto[i+1]) + Math.Abs (0 - posto[i+1]);
      } else {
        sc = sc - Math.Abs (posto[i - 1] - posto[i]) - Math.Abs (posto[i ] - posto[i +  1]) + Math.Abs (posto[i - 1] - posto[i + 1]);
      }

      Console.WriteLine (sc);
    }

    //Console.WriteLine (cost);


  }
}

Measured memory_bytes: 26844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int a,b,count = 0;
 cin >> a >> b;
 
  for (; a <= b;a++){
    int v,w,x,y,z;
    v = a / 10000;
    w = a / 1000 % 10;
    x = a / 100 % 10;
    y = a / 10 % 10;
    z = a / 1 % 10;
    if(v==z && w==y){
      count++;
    }
  }
 cout << count << endl;
 
}

Measured memory_bytes: 3540
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <functional>

using namespace std;
using ll = long long;

#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define REP(i,n) for(int i = 0; i < int(n); i++)
#define VI vector<int>
#define VVI vector<vector<int>>
#define VVVI vector<vector<vector<int>>>
#define VL vector<ll>
#define PAIR pair<int,int>
#define MP make_pair
#define VP vector<pair<int,int>>
#define VS vector<string>
#define PQUE priority_queue<int> //5,5,4,3,3,2,...
#define REPQUE priority_queue<int, vector<int>, greater<int>> //1,1,2,3,4,4,5,...
#define SUM(obj) accumulate((obj).begin(), (obj).end(), 0)
#define SORT(obj) sort((obj).begin(), (obj).end()) // 1,2,3,4,5...
#define RESORT(obj) sort((obj).begin(), (obj).end(), greater<int>()) // 5,4,3,2,1...
#define UB(obj,n) upper_bound((obj).begin(), (obj).end(), n) //itr > n
#define LB(obj,n) lower_bound((obj).begin(), (obj).end(), n) //itr>= n

const ll MOD = (ll)1e9 + 7;


int main() {
	int N, M;
	cin >> N >> M;
	cout << pow(2, M)*(1800 * M + 100 * N) << endl;	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>

typedef long long ll;

using namespace std;

int main()
{
    ll n;
    cin >> n;

    set<pair<char, ll>> input;

    for (ll i=0; i<n; i++)
    {
        char c; int d;
        cin >> c >> d;

        input.insert(make_pair(c, d));
    }

    vector<char> kind ({'S', 'H', 'C', 'D'});

    for (auto i : kind)
    {
        for (ll j=1; j<=13; j++)
        {
            if (input.find(make_pair(i, j)) == input.end())
                cout << i << ' ' << j << endl;
        }
    }


    return 0;
}



Measured memory_bytes: 3088
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
#define double long double
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
#define eps 1e-12 
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int N; cin >> N;
	VI A(N), B(N);
	REP(i, N)cin >> A[i] >> B[i];
	REP(i, N - 2) {
		if (A[i] == B[i] && A[i + 1] == B[i + 1] && A[i + 2] == B[i + 2]) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}



Measured memory_bytes: 3600
#include <set>
#include <map>
#include <cmath>
#include <ctime>
#include <bitset>
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <algorithm>
#define PR pair
#define fi first
#define se second
#define mk make_pair
#define pb push_back
#define REP(i, x, y)   for(int i = (int)(x); i <= (int)(y); i++)
#define FOR(i, x, y)   for(int i = (int)(x); i <  (int)(y); i++)
#define PER(i ,x, y)  for(int i = (int)(x); i >= (int)(y); i--)
#define CH	         ch = getchar()
#define Exit(...)    printf(__VA_ARGS__), exit(0)
#define dln()        fprintf(stderr,"\n")
#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;
typedef double	  db;
typedef long long LL;
typedef vector<int> VI;
typedef vector<VI > VII;
typedef PR<int,int> PII;
typedef vector<PII> VPI;
const	int inf=2e9;
const	LL Inf=1e10;
const	int P=1e9+7;
const	int N=1000005;

inline LL IN(){
	LL x = 0;
	int ch = 0, f = 0;
	for (CH; ch != -1 && (ch < 48 || ch > 57); CH) f = (ch == '-');
	for (; ch >= 48 && ch <= 57; CH) x = (x << 1) + (x << 3) + ch - '0';
	return f ? (-x) : x;
}
template<typename T> inline int chkmin(T &a, const T &b){if(b < a) return a = b, 1; return 0;}
template<typename T> inline int chkmax(T &a, const T &b){if(b > a) return a = b, 1; return 0;}

void renew(int &x, const int &y){
	x += y;
	if(x >= P) x -= P;
	if(x <  0) x += P;
}

int Pow(int x, int y, int p){
	int a = 1;
	for (; y; y >>= 1, x = (LL)x * x %p) if(y & 1) a=(LL)a * x%p;
	return a;
}

int n, m, k;
int f[N], g[N];
int fac[N], inv[N];

int C(int x, int y){
	if(x < 0 || y < 0 || x < y) return 0;
	return (LL)fac[x] * inv[y] % P * inv[x - y] % P;
}

int main(){
	scanf("%d%d%d", &n, &m, &k);
	fac[0] = fac[1] = inv[0] = inv[1] = 1;
	REP(i, 2, 1000000){
		fac[i] = (LL)fac[i - 1] * i % P;
		inv[i] = (LL)inv[P % i] * (P - P / i) % P;
	}
	REP(i, 2, 1000000){
		inv[i] = (LL)inv[i - 1] * inv[i] % P;
	}
	int ff = 1;
	int ans = 0;
	REP(x, 0, m + k){
		int l = max(0, x - k);
		int r = min(x, m);
		int sum = 0;
		
		if(r == x){
			sum = ff;
		}else{
			if(x == m + 1){
				g[x] = ff;
				renew(g[x], -1);
			}
			g[x + 1] = (0LL + g[x] + g[x] + P - C(x, m)) % P;
			sum = g[x];
		}
		if(l > 0){
			if(l == 1){
				f[x] = 1;
			}
			f[x + 1] = (0LL + f[x] + f[x] + C(x, k)) % P;
			renew(sum, -f[x]);
		}
		
		renew(ans, (LL)sum * C(n - 1 + x, x) % P * Pow(3, m + k - x, P) % P);
		ff = (ff << 1) % P;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 10368
<?php
$input=explode(' ',trim(fgets(STDIN))); // input[0]は全数、input[1]はXの購読者数、input[2]はYの購読者数
$min = min($input);
$prepare = $input[1]+$input[2];
$prepare2 = $prepare - $input[0];
if ($prepare2 < 0) {
	echo $min.' 0';
}else{
	echo $min." ".$prepare2;
}
exit();

Measured memory_bytes: 4728
#include <bits/stdc++.h>

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod =(1e9)+7;
using P = pair<ll,ll>;

int main(){
    ll sx,sy,tx,ty;cin >>sx>>sy>>tx>>ty;
    for (int i = 0; i < tx - sx; ++i) {
        cout <<'R';
    }
    for (int i = 0; i < ty - sy; ++i) {
        cout <<'U';
    }
    for (int i = 0; i < tx - sx; ++i) {
        cout <<'L';
    }
    for (int i = 0; i < ty - sy; ++i) {
        cout <<'D';
    }
    cout <<'L';
    for (int i = 0; i <= ty - sy; ++i) {
        cout <<'U';
    }
    for (int i = 0; i <= tx - sx; ++i) {
        cout <<'R';
    }
    cout <<'D';cout <<'R';
    for (int i = 0; i <=ty - sy; ++i) {
        cout <<'D';
    }
    for (int i = 0; i <= tx - sx; ++i) {
        cout <<'L';
    }
    cout <<'U'<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;

int main() {
  vector<int> spot(5,0);
  for (int i = 0; i < 5; i++) {
	cin >> spot[i];
  }
  
  int dist = 0;

  cin >> dist;
  int check = 0;

  if (spot.at(4) - spot.at(0) > dist) {
	check = 1;
  }
  
  if (check == 0) {
	cout << "Yay!" << endl;
  } else {
	cout << ":(" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void solve(){
    int n,m,x,y=0;
    cin>>n>>m;
    for(int i=1;i<=m;++i){
        cin>>x;
        y+=x;
    }
    if(n<=y)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    //cout<<ceil(1.0*n/m)<<endl;
}
int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int x = in.nextInt();
        int c = 1; // because x>=1
        int d = 0;
        for(int i=0; i<n; i++) {
            int l = in.nextInt();
            d += l;
            if(d<=x) {
                c++;
            }
        }
        System.out.println(c);
    }
}


Measured memory_bytes: 23252
# cs: c nnected switches
n, m = map(int, input().split())

# cs: connected switches
cs = [list(map(int, input().split())) for _ in range(m)]
ps = list(map(int, input().split()))

# bit全探索(0: すべてoffは不要)
ans = 0
# on: 0:消えてる、1:点いてる
# 10: 1 2  3   4 
# 0b: 1 10 11, 100..
for on in range(2**n):
    # bin: バイナリ文字列に変換
    # 3 -> '0b11'
    # rust で右0埋め
    patern = bin(on)[2:].rjust(n, '0')
    ok = True

    for i in range(m):
        ct = 0
        for j in range(cs[i][0]):
            if patern[cs[i][j+1] - 1] == '1':
                ct += 1
        if ct%2 != ps[i]:
            ok = False
    if ok:
        ans += 1
print(ans)


Measured memory_bytes: 9192
import math
N = int(input())
k = 10**9
l = ['0','0']
if N<k:
    l = l + ['0','1']
    l.append(str(N))
    l.append('0')
else:
    m = math.ceil(N / k)
    M = N % k
    if M==0:
        l = l + [str(k),'0']
    else:
        l = l + [str(k),'1']
    s = N % k
    x_2 = k - s
    l.append(str(x_2))
    l.append(str(m))
print(' '.join(l))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define maxn 200086

using namespace std;

int n;
int a[maxn], b[maxn];

inline bool check(int x){
	for(int i = 1;i <= 2 * n - 1;i++) b[i] = a[i] >= x;
    x = 0;
	for(int i = 2;i <= 2 * n - 1;i++){
		if(b[i] == b[i - 1]){
			if(abs(i - n) < abs(x - n)) x = i;
			if(abs(i - 1 - n) < abs(x - n)) x = i - 1;
		}
	}
	if(!x) return b[n] ^ ((n - 1) & 1);
	return b[x];
}

int main(){
	scanf("%d", &n);
	for(int i = 1;i <= 2 * n - 1;i++) scanf("%d", &a[i]);
	int l = 1, r = 2 * n - 1, mid;
	while(l < r){
		mid = (l + r >> 1) + 1;
		if(check(mid)) l = mid;
		else r = mid - 1;
	}
	printf("%d", l);
}

Measured memory_bytes: 5316
N, K = gets.split.map(&:to_i)
ans = 0.to_f
i = 0
N.downto(1){|x|
    #puts ("x=#{x} i=#{i}")
    if (x * (2**i) >= K)
        ans += (1/N.to_f) * (1.to_f/(2**i).to_f)
    else
        i += 1
        redo
    end
}

puts ans


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	int h, n;
	cin >> h >> n;
	V a(n), b(n);
	rep(i, n) {
		cin >> a[i] >> b[i];
	}
	V dp(h + 1, upper);
	dp[0] = 0;
	rep(i, n) {
		rep(j, h) {
			int nj = min(h, j + a[i]);
			chmin(dp[nj], dp[j] + b[i]);
		}
	}
	cout << dp[h] << endl;
	return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main(){
    int N;  cin >> N;
    vector<int> A(N,0);
    for(int i=0; i<N; i++) cin >> A[i];

    multiset<int> col;
    for(int a : A){
        auto itr = col.upper_bound(-a);
        if(itr == col.end()){
            col.insert(-a);
            continue;
        }

        col.erase(itr);
        col.insert(-a);
    }
    cout << col.size() << endl;
}


Measured memory_bytes: 5376
#include "bits/stdc++.h"
// Custom Header <<<
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n)      for(int i(s); i < int(n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;
// >>>

signed main()
{
    int N, M;
    bool a[100010] {};

    cin >> N >> M;
    rep(i, 0, M) {
        int x;
        cin >> x;
        a[x] = true;
    }

    i64 dp[100010] {};
    dp[0] = 1;
    rep(i, 0, N+1) {
        if (a[i]) continue;
        (dp[i+1] += dp[i]) %= MOD;
        (dp[i+2] += dp[i]) %= MOD;
    }

    cout << dp[N] << endl;

    return 0;
}

/* vim:set foldmethod=marker foldmarker=<<<,>>> : */


Measured memory_bytes: 1152
N = int(input())
A = list(map(int, input().split()))

ifContinue = True
while ifContinue:
    ifContinue = False
    counter = 0
    for i in range(N):
        if not A[i] == 0:
            counter += 1
            if counter == 2:
                ifContinue = True
                break
    min = 10**9+1
    index = -1
    for i in range(N):
        if A[i] < min and not A[i] == 0:
            min = A[i]
            index = i

    for i in range(N):
        if i == index or A[i] == 0:
            continue
        else:
            A[i] = A[i] % min

print(max(A))


Measured memory_bytes: 14432
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template<class T>
void read(T&);
template<class T>
void write(const T&);

typedef long long ll;
typedef const long long & cll;
typedef const int & ci;
typedef std::pair<int, int> pii;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;
using std::min;
using std::max;
using std::abs;
using std::sort;

int main () {
  int a, b;
  read(a), read(b);
  if (a > 9 || b > 9) {
    puts("-1");
  } else {
    write(a * b), EL;
  }
  return 0;
}

template<class T>
inline void read(T &Re) {
  T k = 0;
  char ch = getchar();
  int flag = 1;
  while (!isNum(ch)) {
    if (ch == '-') {
      flag = -1;
    }
    ch = getchar();
  }
  while (isNum(ch)) {
    k = (k << 1) + (k << 3) + ch - '0';
    ch = getchar();
  }
  Re = flag * k;
}
template<class T>
inline void write(const T &Wr) {
  if (Wr < 0) {
    putchar('-');
    write(-Wr);
  } else {
    if (Wr < 10) {
      putchar(Wr + '0');
    } else {
      write(Wr / 10);
      putchar((Wr % 10) + '0');
    }
  }
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))


def gcd(a, b):
    r = a % b
    if 0 == r:
        return b
    else:
        return gcd(b, r)


def gcd_for_arr(l):
    tmp = gcd(l[0], l[1])
    for i in range(2, len(l)):
        tmp = gcd(tmp, l[i])
    return tmp


print(gcd_for_arr(a))


Measured memory_bytes: 14224
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=2000010;
const LL mod=1e9+7;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int x[7],y[7];
LL fac[N],ifac[N],ans,ret;
inline LL qpow(LL a,LL b)
{
	LL ret=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ret=ret*a%mod;
	return ret;
}
inline void init(int n)
{
	fac[0]=ifac[0]=1;
	For(i,1,n)fac[i]=fac[i-1]*i%mod;
	ifac[n]=qpow(fac[n],mod-2);
	rFor(i,n,2)ifac[i-1]=ifac[i]*i%mod;
}
inline LL C(int a,int b)
{
	return fac[a+b]*ifac[a]%mod*ifac[b]%mod;
}
inline LL C(int a,int b,int c,int d)
{
	//printf("%d %d %d %d:\n",a,b,c,d);
	//printf("%lld\n",(C(c+1,d+1)+mod-C(a,d+1)+mod-C(c+1,b)+C(a,b))%mod);
	assert(a<=c);
	assert(b<=d);
	return (C(c+1,d+1)+mod-C(a,d+1)+mod-C(c+1,b)+C(a,b))%mod;
}
int main()
{
	For(i,1,6)read(x[i]);
	For(i,1,6)read(y[i]);
	init(2000005);
	For(i,x[3],x[4])
	{
		int X=i,Y=y[3]-1;
		ret=(X+Y+1)*C(X-x[2],Y-y[2],X-x[1],Y-y[1])%mod;
		Y++;
		ret=ret*C(x[5]-X,y[5]-Y,x[6]-X,y[6]-Y)%mod;
		ans=(ans+mod-ret)%mod;
	}
	For(i,y[3],y[4])
	{
		int X=x[3]-1,Y=i;
		ret=(X+1+Y)*C(X-x[2],Y-y[2],X-x[1],Y-y[1])%mod;
		X++;
		ret=ret*C(x[5]-X,y[5]-Y,x[6]-X,y[6]-Y)%mod;
		ans=(ans+mod-ret)%mod;
	}
	For(i,x[3],x[4])
	{
		int X=i,Y=y[4];
		ans=(ans+(X+Y+1)*C(X-x[2],Y-y[2],X-x[1],Y-y[1])%mod*C(x[5]-X,y[5]-Y-1,x[6]-X,y[6]-Y-1)%mod)%mod;
	}
	For(i,y[3],y[4])
	{
		int X=x[4],Y=i;
		ans=(ans+(X+Y+1)*C(X-x[2],Y-y[2],X-x[1],Y-y[1])%mod*C(x[5]-X-1,y[5]-Y,x[6]-X-1,y[6]-Y)%mod)%mod;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 31488
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    unsigned long long n, ans = 0, mod = 1000000007;
    cin >> n;
    vector<unsigned long long> a(n);
    unsigned long long po = 0, tot = 0; 
    for(int i = 0; i < n; ++i){
        cin >> a.at(i);
        po += (a.at(i) * a.at(i)) % mod;
        tot += a.at(i);
    }
    tot %= mod; po %= mod;
    ans = (tot * tot) - po;
    ans %= mod;
    //2で割る (逆元を用いる)
	//ans /= 2 を mod 1000000007で行うとこうなる
	ans *= (mod + 1) / 2;
	ans %= mod;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4780
using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            // 各種変数の読み込み
            var s = Console.ReadLine();
            if (s == "Sunny")
            {
                Console.WriteLine("Cloudy");
            }
            else if (s == "Cloudy")
            {
                Console.WriteLine("Rainy");
            }
            else
            {
                Console.WriteLine("Sunny");
            }
#if DEBUG
            Console.ReadKey();
#endif
        }


        private static int Readint()
        {
            // 1行に1つのintが入力されたのを読む
            return int.Parse(Console.ReadLine());
        }

        private static int[] Readints()
        {
            // 1行に複数のintが入力されたのを読む
            var s = Console.ReadLine().Split(' ');
            var output = new int[s.Length];
            for (int i = 0; i < s.Length; i++)
            {
                output[i] = int.Parse(s[i]);
            }
            return output;
        }

        private static int[][] Readints(int n, bool transpose = false)
        {
            // n行それぞれにintが入力されたのを読む
            // output[行番号][列番号]で返す。
            // transposeがtrueのときは、output[列番号][行番号]で返す。
            var s = Console.ReadLine().Split(' ');
            int rownum = s.Length;
            if (transpose)
            {
                var outputs = new int[rownum][];
                for (int j = 0; j < rownum; j++)
                {
                    outputs[j] = new int[n];
                }
                for (int i = 0; i < s.Length; i++)
                {
                    outputs[i][0] = int.Parse(s[i]);
                }
                for (int l = 1; l < n; l++)
                {
                    var temps = Console.ReadLine().Split(' ');
                    for (int i = 0; i < rownum; i++)
                    {
                        outputs[i][l] = int.Parse(temps[i]);
                    }
                }
                return outputs;
            }
            else
            {
                var outputs = new int[n][];
                outputs[0] = new int[rownum];
                for (int i = 0; i < s.Length; i++)
                {
                    outputs[0][i] = int.Parse(s[i]);
                }
                for (int l = 1; l < n; l++)
                {
                    outputs[l] = new int[rownum];
                    var temps = Console.ReadLine().Split(' ');
                    for (int i = 0; i < rownum; i++)
                    {
                        outputs[l][i] = int.Parse(temps[i]);
                    }
                }
                return outputs;
            }
        }
    }
}


Measured memory_bytes: 11092