akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  string S,T; cin>>S>>T;
  int N=S.size(),M=T.size();
  vector<string> dp(M+1);
  rep(i,0,N){
    vector<string> cp(M+1);
    rep(j,0,M){
      if(cp[j].size()>dp[j+1].size()) cp[j+1]=cp[j];
      else cp[j+1]=dp[j+1];
      if(S[i]==T[j]&&dp[j].size()+1>cp[j+1].size()) cp[j+1]=dp[j]+S[i];
    }
    REP(j,0,M) dp[j]=cp[j];
  }
  cout<<dp[M]<<endl;
  }


Measured memory_bytes: 8252
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_solve
{
    class Program
    {
        public const ulong mod = 1000000007;

        static void Main(string[] args)
        {
            var n =Input() ;
            var a = Console.ReadLine().Split().Select(long.Parse).ToArray();
            var b = new int[n+1];

            for(int i = 0; i < n-1; i++)
            {
                b[a[i]]++;
            }
            
            for(int j = 1; j <= n; j++)
            {
                Console.WriteLine(b[j]);
            }



            

        }

        static public long Input()
        {
            return long.Parse(Console.ReadLine());
        }

        static public string[] Input2()
        {
            return Console.ReadLine().Split();
        }
        
        static public long[] Input3()
        {
            string[] data = Console.ReadLine().Split();
            long[] res = new long[data.LongLength];
            for(long i = 0; i < data.LongLength; i++)
            {
                res[i] = long.Parse(data[i]);
            }
            return res;
        }
        public static long Choose(long n, long a)
        {
            long x = 1;
            long y = 1;
            for (long i = 0; i < a; i++)
            {
                x *= n - i;
                y *= i + 1;
            }
            return x / y;
        }

        public static long Gcd(long a, long b)
        {
            long x = Math.Max(a, b);
            long y = Math.Min(a, b);
            if (x % y == 0) return y;
            else return Gcd(y, x % y);
        }

        
       
    }
}


Measured memory_bytes: 44408
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<60;
const int IINF = 1000000000;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

struct mint {
    ll x;
    mint(ll x=0):x((x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    bool operator==(const mint a){
        return (x == a.x);
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return pow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// 2項係数を求める
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

//nが非常に大きく、aが小さい場合
mint choose(int n, int a){
    mint x = 1, y = 1;
    rep(i,a){
        x *= n-i;
        y *= i+1;
    }
    return x/y;
}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    vector<int> counter(N+1,0);
    counter[0] = 3;

    mint ans = 1;
    rep(i,N){
        ans *= counter[A[i]];
        counter[A[i]]--;
        counter[A[i]+1]++;
    }

    cout << ans << endl;

}

Measured memory_bytes: 3920
// Aizu Vol-2 0205: Rock, Paper, Scissors
// 2017.8.6

#include <stdio.h>

int h[6], c[4];

int main()
{
	int i;

	while (1) {
		for (i = 1; i <= 3; i++) c[i] = 0;
		scanf("%d", h + 1), c[h[1]]++;
		if (h[1] == 0) break;
		for (i = 2; i <= 5; i++) scanf("%d", h+i), c[h[i]]++;
		if (c[1] == 5 || c[2] == 5 || c[3] == 5 || (c[1] > 0 && c[2] > 0 && c[3] > 0)) {
			for (i = 1; i <= 5; i++) puts("3");
			continue;
		}
		for (i = 1; i <= 5; i++) {
			if      (h[i] == 1) h[i] = 1 + (c[3] > 0);
			else if (h[i] == 2) h[i] = 1 + (c[1] > 0);
			else                h[i] = 1 + (c[2] > 0);
		}
		for (i = 1; i <= 5; i++) putchar(h[i] + '0'), putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 588
#include <iostream>
#include <math.h>
using namespace std;

int n, a[10], odd = 1, ans;

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 1) {
			odd *= 1;
		}
		else {
			odd *= 2;
		}
	}

	ans = pow(3, n);
	ans -= odd;

	cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
#define spln(i,n) (i==n?'\n':' ')
#define fac_init(n){fac[0]=fac[1]=inv[1]=fi[0]=fi[1]=1;fz(i,2,n){fac[i]=1ll*fac[i-1]*i%mod;inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;fi[i]=1ll*fi[i-1]*inv[i]%mod;}}
using namespace std;
inline void read(int &x)
{
	char c;int f=1;
	while(!isdigit(c=getchar()))if(c=='-')f=-1;
	x=(c&15);while(isdigit(c=getchar()))x=(x<<1)+(x<<3)+(c&15);
	x*=f;
}
int n,m,mod,i,j,k,dp[305][305],sum[305][305],c[305][305];
int main()
{
	scanf("%d%d%d",&n,&m,&mod);
	c[0][0]=1;
	fz1(i,n){
		c[i][0]=1;
		fz1(j,i) c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
	}
	fd0g(i,m){
		dp[i][1]=1;
		fz1(j,n+1){
			fz1(k,n+1-j){
				inc(dp[i][j+k],1ll*dp[i][j]*sum[i+1][k]%mod*c[j+k-2][k-1]%mod)
			}
		}
		fz1(j,n+1){
			sum[i][j]=(sum[i+1][j]+dp[i][j])%mod;
		}
	}
	printf("%d\n",dp[0][n+1]);
	return 0;
}

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

int main(int argc, char const *argv[])
{
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < 3; i++)
    {
        if (s[i] == t[i])
        {
            ans++;
        }
        
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3","unroll-loops")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}


main(){
	int x,y;
	cin>>x>>y;
	if(x<y)dump(min(y-x,abs(x+y)+1));
	else dump(min(x-y+2,abs(x+y)+1));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

ii arr[200000];

ll power(ll a, ll b, ll mod){ // to calculate a^b %mod
    if(b == 0)
        return 1;
    ll temp = power(a,b>>1,mod)%mod;
    temp = (temp*temp)%mod;
    if(b&1)
        temp = temp*a%mod;
    return temp;
}

void buildtable(void){
    ll count=1;
    for(ll i=1;i<=199999;i++){
        count*=i;
        if(count>1000000007){
            count=count%1000000007;
        }
        arr[i].fi=count;
        ll invmod=power(count,1000000005,1000000007);
        arr[i].se=invmod;
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll h,w,a,b;
    cin>>h>>w>>a>>b;
    arr[0].fi=1;
    arr[0].se=1;
    buildtable();
    ll ans=0;
    for(ll i=b;i<=w-1;i++){
        ll count=arr[h-a-1+i].fi*arr[i].se;
        count=count%1000000007;
        count*=arr[h-a-1].se;
        count=count%1000000007;

        //cout<<count<<endl;

        ll count2=arr[a-1+w-1-i].fi*arr[a-1].se;
        count2=count2%1000000007;
        count2*=arr[w-1-i].se;
        count2=count2%1000000007;

        //cout<<count2<<endl;

        count*=count2;
        count%=1000000007;
        ans+=count;
        ans%=1000000007;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

X = i()
print(lcm(X,360)//X)

Measured memory_bytes: 77468
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000;
int main(){
  int A, B, Q;
  cin >> A >> B >> Q;
  set<long long> st1;
  for (int i = 0; i < A; i++){
    long long s;
    cin >> s;
    st1.insert(s);
  }
  set<long long> st2;
  for (int i = 0; i < B; i++){
    long long t;
    cin >> t;
    st2.insert(t);
  }
  for (int i = 0; i < Q; i++){
    long long x;
    cin >> x;
    long long L1, R1, L2, R2;
    if (st1.count(x)){
      L1 = 0;
      R1 = 0;
    } else {
      auto itr = st1.lower_bound(x);
      if (itr == st1.end()){
        R1 = INF;
      } else {
        R1 = *itr - x;
      }
      if (itr == st1.begin()){
        L1 = INF;
      } else {
        L1 = x - *prev(itr);
      }
    }
    if (st2.count(x)){
      L2 = 0;
      R2 = 0;
    } else {
      auto itr = st2.lower_bound(x);
      if (itr == st2.end()){
        R2 = INF;
      } else {
        R2 = *itr - x;
      }
      if (itr == st2.begin()){
        L2 = INF;
      } else {
        L2 = x - *prev(itr);
      }
    }
    long long ans = INF;
    ans = min(ans, max(L1, L2));
    ans = min(ans, max(R1, R2));
    ans = min(ans, L1 * 2 + R2);
    ans = min(ans, R1 * 2 + L2);
    ans = min(ans, L2 * 2 + R1);
    ans = min(ans, R2 * 2 + L1);
    cout << ans << endl;
  }
}

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

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define ll long long 
#define ld long double
#define pb push_back
#define F first
#define S second
#define I insert
#define pll pair<ll,ll> 
#define vll vector<ll> 
#define vpll vector< pll >
ll M=998244353;
ll ncr[4005][4005];
ll to[4005];
ll dp[2005][2005];
void pre(){
	ll a,b,c,d,i,j,k;
	ncr[0][0]=1;
	for(i=1;i<4005;i++){
		for(j=0;j<=i;j++){
			if(j==0)ncr[i][j]=1;
			else (ncr[i][j]=ncr[i-1][j]+ncr[i-1][j-1])%=M;
		}
	}
	to[0]=1;
	for(i=1;i<4005;i++){to[i]=(to[i-1]*2)%M;}
	// for(i=1;i<=2000;i++)dp[i][1]=2;
	// dp[0][0]=1;
	// for(i=1;i<=2000;i++){
	// 	for(j=1;j<=2000;j++){

	// 	}
	// }
}
int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	ll k,n,a,b,c,d,i,j;ll p,q,r,s;pre();
	cin>>k>>n;ll ans=0;
	// for(i=0;i<=5;i++){
	// 	for(j=0;j<=5;j++){cout<<ncr[i][j]<<" ";}
	// 		cout<<"\n";
	// }
	// for(i=0;i<5;i++)cout<<to[i]<<" ";
	for(i=2;i<=2*k;i++){
		ans=0;//if(i!=5)continue;
		if(i<=k+1){a=i-1;}else a=k-(i-k)+1;
		c=a/2;b=a%2;d=k-a;trace(i,b,c,d);
		for(j=0;j<=c;j++){
			if(((n-j)+(d+j-1))>=0&&(d+j-1)>=0){if((d+j)!=0)p=ncr[(n-j)+(d+j-1)][d+j-1];else p=1;
			p=(p*to[j])%M;(ans+=(ncr[c][j]*p)%M)%=M;}
			if((b==1)&&((n-j-1)+(d+j-1))>=0&&(d+j-1)>=0){if((d+j)!=0)p=ncr[(n-1-j)+(d+j-1)][d+j-1];else p=1;
			p=(p*to[j])%M;(ans+=(ncr[c][j]*p)%M)%=M;}
			trace(j,ans);
		}
		cout<<ans<<"\n";
	}
	return 0;
}

Measured memory_bytes: 126336
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define nibu(K,x) binary_search(K.begin(),K.end(),x)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
#define sz(x) x.size()
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define out(x) cout<<x<<endl
#define put(x) out(x)
#define in(x) cin>>x
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
using ll = long long;
using vl = vector<ll>;
using vs = vector<string>;
const double pi = 3.14159265358979;

ll  N;

ll sai(ll i,ll ans){
  if(i<=1) return i ;
  return sai(i-1,ans)+i;
}

int main() {
 string S;
  in(S);
  ll s=0;
  ll w=0;
  N=sz(S);
  rep(i,N){
   if(S[i]=='W'){
     s++;
     w+=i; 
   }
  }
if(s==0){
out(0);
return 0;
}
 out(w-sai(s-1,0));
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
map<int, int> m;
bool possible(int l){
  int k = 0;
  while(l > 0){
    k = l % 10;
    l = l/10;
    if(m[k] == 1) return false;
  }
  return true;
}
int main(){
  //map<int, int> m;
  int n, k, l;
  cin >> n >> k;
  for(int i=0; i<k; i++){
    cin >> l;
    m[l] = 1;
  }
  if(k == 0 || k == 10) cout << n << endl;
  else{
    while(true){
      if(possible(n)) {
        cout << n << endl;
        break;
      }
      n+=1;
    }
  }
}
  

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        k: usize,
        s: Chars
    };
    if s.len() <= k {
        println!("{}", s.iter().collect::<String>());
    } else {
        println!("{}{}", s[0..k].iter().collect::<String>(), "...");
    }
}


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

int main() {
  int n;
  cin >> n;
  for (int i=0; i<26; i++){
    for (int j=0; j<14; j++){
      if (4*i+7*j==n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b) - 1; (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

int asc(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}

int desc(const void *a, const void *b) {
    return *(int *)b - *(int *)a;
}
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

int main()
{
    int c[3][3],a[3],b[3];
    rep(i, 3){
        rep(j, 3){
            cin >> c[i][j];
        }
    }
    rep(i, 101){
        a[0] = i;
        b[0] = c[0][0] - a[0];
        b[1] = c[0][1] - a[0];
        b[2] = c[0][2] - a[0];
        a[1] = c[1][0] - b[0];
        a[2] = c[2][0] - b[0];
        rep(j, 3){
            rep(k, 3){
                if (c[j][k] != a[j] + b[k]) {
                    goto loopend;
                }
            }
        }
        Yes;
        return 0;
    loopend:;
    }
    No;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    string S; cin >> S;
    int mi = S.size();
    rep(i, S.size()-1) {
        if (S[i] != S[i+1]) {
            int T = max(i+1, (int)S.size()-(i+1));
            mi = min(mi, T);
        }
    }
    cout << mi << endl;
}


Measured memory_bytes: 3752
def calc(l):
    r = 0
    finish = False
    while True:
        for i in range(0, len(l)):
            if l[i] % 2 == 0:
                l[i] = l[i]//2
            else:
                finish = True
                break
        if finish:
            break
        r += 1

    return r


_ = input()
l = list(map(int, input().split()))
r = calc(l)
print(r)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))

int get_int(void) {
  int num;
  scanf("%d", &num);
  return num;
}

enum {
    ENUM_A,
    ENUM_C,
    ENUM_G,
    ENUM_T,
    ENUM_ALL,
};

#define SIZE 3
int blacklist[][SIZE] = {
    {ENUM_A, ENUM_G, ENUM_C},
    {ENUM_G, ENUM_A, ENUM_C},
    {ENUM_A, ENUM_C, ENUM_G},
};
int check(int *arr, int mask) {
    int i, j;
    int ans = 1;
    for(i = 0; i < sizeof(blacklist)/sizeof(blacklist[0]); i++) {
        if(!((1<<i) & mask)) continue;
        int flag = 1;
        for(j = 0; j < SIZE; j++) {
            if(arr[j] != blacklist[i][j]) { flag = 0; break; }
        }
        if(flag) ans = 0;
    }
    return ans;
}

#define NUM_MAX 100
#define DIVISOR ((int64_t)(1e+9)+7)

int main(void) {
    int num = get_int();
    static int64_t dp[NUM_MAX+1][ENUM_ALL][ENUM_ALL][ENUM_ALL][ENUM_ALL];
    int n;
    int i, j, k, l;
    // for n==3
    for(i = 0; i < ENUM_ALL; i++) {
        for(j = 0; j < ENUM_ALL; j++) {
            for(k = 0; k < ENUM_ALL; k++) {
                int idx[3] = {i, j, k};
                if(check(idx, (1<<3)-1)) dp[3][ENUM_T][i][j][k] = 1;
            }
        }
    }

    int prev;
    for(n = 4; n <= num; n++) {
        for(i = 0; i < ENUM_ALL; i++) {
            for(j = 0; j < ENUM_ALL; j++) {
                for(k = 0; k < ENUM_ALL; k++) {
                    for(l = 0; l < ENUM_ALL; l++) {
                        int idx[SIZE] = {j, k, l};
                        int idx2[SIZE] = {i, k, l};
                        int idx3[SIZE] = {i, j, l};
                        int flag = 1;
                        flag &= check(idx, (1<<3)-1);
                        flag &= check(idx2, 1);
                        flag &= check(idx3, 1);
                        int64_t res = 0;
                        if(!flag) continue;
                        for(prev = 0; prev < ENUM_ALL; prev++) {
                            res = (dp[n-1][prev][i][j][k]+res)%DIVISOR;
                        }
                        dp[n][i][j][k][l] = res;
                    }
                }
            }
        }
    }
    int64_t ans = 0;
    for(i = 0; i < ENUM_ALL; i++) {
        for(j = 0; j < ENUM_ALL; j++) {
            for(k = 0; k < ENUM_ALL; k++) {
                for(l = 0; l < ENUM_ALL; l++) {
                    ans = (ans + dp[num][i][j][k][l])%DIVISOR;
                }
            }
        }
    }
    printf("%d\n", (int)ans);
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main() {
  int x;
  scanf("%d", &x);
  long long int a[x], maximum = 1e18;
  long long int prod = 1;
  long long int flag = 0; 
  long long int num = 0;
  
  for (int i = 0; i < x; i++) {
    scanf("%lld", &a[i]);
    flag = (a[i] > maximum) ? 1 : flag;
    prod *= a[i];
    (a[i]) ? maximum /= a[i] : num = 1;
  }

  (num) ? puts("0") : ((flag) ? puts("-1") : printf("%lld\n", prod));
  return 0;
}

Measured memory_bytes: 2504
IDENTIFICATION DIVISION.
PROGRAM-ID. PROGRAM_ID.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 LN             PIC X(3).
01 a              PIC 9(1).
01 b              PIC 9(1).
01 i              PIC 9(2).
01 ans            PIC X(9).

PROCEDURE DIVISION.
  ACCEPT LN.
  UNSTRING LN DELIMITED BY SPACE INTO a b.
  IF a < b
      PERFORM VARYING i FROM 1 BY 1 UNTIL b < i
          MOVE a TO ans(i:1)
      END-PERFORM
  ELSE
      PERFORM VARYING i FROM 1 BY 1 UNTIL a < i
          MOVE b TO ans(i:1)
      END-PERFORM
  END-IF.
  DISPLAY ans.
  STOP RUN.


Measured memory_bytes: 636
#include <iostream>
using namespace std;

#define F(d, i) ((d) * (i) * (i))

int main(void)
{
	int d;

	while(cin >> d) {
		unsigned long s = 0;

		for(int i = d; i < 600; i += d) {
			s += F(d, i);
		}

		cout << s << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>

int main()
{
  int j, k;
  int fib[45];
  fib[0] = 1;
  fib[1] = 1;
  
  for(j = 2; j < 45; ++j) 
  {
    fib[j] = fib[j-1] + fib[j-2];
  }
  scanf("%d", &k);
  printf("%d\n", fib[k]);
  return 0;
}



Measured memory_bytes: 2052
package main

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

const pi = math.Pi

var mod int = pow(10, 9) + 7
var Umod uint64 = 1000000007
var ans, cnt int

func main() {
	reader.Split(bufio.ScanWords)
	N, _ := strconv.Atoi(read())
	A, B := make([]int, N), make([]int, 0, N)
	for i := 0; i < N; i++ {
		A[i], _ = strconv.Atoi(read())
	}
	for i := 0; i < N; i++ {
		insert := binary_tree(A[i], B)
		if insert == len(B) {
			B = append(B, A[i])
		} else {
			B[insert] = A[i]
		}
	}
	fmt.Println(len(B))
}

func binary_tree(target int, arr []int) int {
	var left, right = -1, len(arr)
	for left+1 < right {
		mid := (left + right) / 2
		if arr[mid] < target {
			right = mid
		} else {
			left = mid
		}
	}
	return right
}

/*  ----------------------------------------  */

var reader = bufio.NewScanner(os.Stdin)

func read() string {
	reader.Scan()
	return reader.Text()
}

func lcm(x, y int) int {
	return (x / gcd(x, y)) * y
}

func gcd(x, y int) int {
	if x%y == 0 {
		return y
	} else {
		r := x % y
		return gcd(y, r)
	}
}

var fac [1000000]int
var finv [1000000]int
var inv [1000000]int

func combination_init() {
	fac[0], fac[1] = 1, 1
	finv[0], finv[1] = 1, 1
	inv[1] = 1

	// invは a^(-1) mod p
	// pをaで割ることを考える

	// p/a*(a) + p%a = p
	// p/a*(a) + p%a = 0          (mod p)
	// -p%a = p/a*(a)             (mod p)
	// -p%a *a^(-1)= p/a          (mod p)
	// a^(-1)= p/a * (-p%a)^(-1)  (mod p)
	// a^(-1) =

	for i := 2; i < 1000000; 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
	}
}

func combination(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[y] * finv[x-y] % mod) % mod
	//return fac[x] / (fac[y] * fac[x-y])
}

func permutation(x, y int) int {
	if x < y {
		return 0
	}
	if fac[0] != 1 {
		combination_init()
	}
	return fac[x] * (finv[x-y] % mod) % mod
	//return fac[x] / fac[x-y]
}

func max(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Max(float64(x[i]), float64(res)))
	}
	return res
}

func min(x ...int) int {
	var res int = x[0]
	for i := 1; i < len(x); i++ {
		res = int(math.Min(float64(x[i]), float64(res)))
	}
	return res
}
func pow(x, y int) int { return int(math.Pow(float64(x), float64(y))) }
func abs(x int) int    { return int(math.Abs(float64(x))) }
func floor(x int) int  { return int(math.Floor(float64(x))) }
func ceil(x int) int   { return int(math.Ceil(float64(x))) }

type SortBy [][]int

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	return a[i][1] < a[j][1]
}

type PriorityQueue []int

func (h PriorityQueue) Len() int            { return len(h) }
func (h PriorityQueue) Less(i, j int) bool  { return h[i] < h[j] }
func (h PriorityQueue) Swap(i, j int)       { h[i], h[j] = h[j], h[i] }
func (h *PriorityQueue) Push(x interface{}) { *h = append(*h, x.(int)) }
func (h *PriorityQueue) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}


Measured memory_bytes: 3840
N = int(input())

for h in range(1, 3501):
    for n in range(1, 3501):
        if (4 * h * n - N * (h + n)) != 0:
            if (N * h * n) / (4 * h * n - N * (h + n)) == (N * h * n) // (4 * h * n - N * (h + n)):
                w = (N * h * n) // (4 * h * n - N * (h + n))
                if w > 0:
                    print(h, n, w)
                    exit()

Measured memory_bytes: 42092
#include<stdio.h>
#define MAX 100005
#define	NIL -1

struct Node{ 
	int p,l,r;
};

struct Node T[MAX]; 

int depth(int x){
	if(T[x].p == NIL){
		return 0;
	} else {
		return 1+depth(T[x].p);
	}
}

int degree(int x){
	if(T[x].l != NIL && T[x].r != NIL){
		return 2;
	}else if(T[x].l != NIL || T[x].r != NIL){
		return 1;
	}else{
		return 0;
	}
}

int sibling(int p,int x){
	if(p == NIL){
		return NIL;
	} else if(T[p].l == x){
		return T[p].r;
	} else {
		return T[p].l;
	}
}

int height(int x){
	int l_h = 0, r_h = 0;

	if(x == NIL){
		return 0;
	}

	if(T[x].l != NIL){
		l_h = height(T[x].l)+1;
	}
	if(T[x].r != NIL){
		r_h = height(T[x].r)+1;
	}

	if(l_h > r_h){
		return l_h;
	}else{
		return r_h;
	}
}


void print(int u){
	printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, " ,u ,T[u].p ,sibling(T[u].p,u) ,degree(u) ,depth(u) ,height(u));

	if(T[u].p == NIL){
		printf("root\n");
	}else if(T[u].l == NIL && T[u].r == NIL){
		printf("leaf\n");
	}else{
		printf("internal node\n");
	}
}

int main(){
	int n,i,id,right,left;

	scanf("%d",&n);

	for(i = 0; i < n; i++){
		T[i].p = NIL;
		T[i].l = NIL;
		T[i].r = NIL;
	}

	for(i = 0; i < n; i++){
		scanf("%d%d%d",&id ,&right ,&left);

		T[right].p = id;
		T[left].p = id;
		T[id].l = right;
		T[id].r = left;
	}

	for(i=0; i<n; i++){
		print(i);
	}
	return 0;
}

Measured memory_bytes: 612
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;

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

  int a,b,c;
  cin >> a >> b >> c;
  
  int x = a%b;
  
  int flag[b] = {};
  
  int r = x;
  while(flag[r] == 0){
    flag[r] = 1;
    r += x;
    r %= b;
  }
  
  if(flag[c] == 1) cout << "YES" << endl;
  else        cout << "NO"  << endl;

  return 0;
}

Measured memory_bytes: 256
<?php

while (($line = trim(fgets(STDIN)))) {
    sscanf($line, '%d %d', $H, $W);
    if ($H === 0 && $W === 0) {
        break;
    }

    for ($i = 0; $i < $H; $i++) {
        for ($j = 0; $j < $W; $j++) {
            echo '#';
        }
        echo PHP_EOL;
    }
    echo PHP_EOL;
}

Measured memory_bytes: 6556
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 200005;

LL d, minn, TL[N], TR[N], r;
int tab[N], c, i, n, ind, l, jump[N], up[N];

int main() {
scanf("%d", &n);
for (i=1;i<=n;i++) scanf("%d", &tab[i]);
TR[n] = 0;
jump[n] = n;
for (i = n - 1;i>=1;i--) {
	if (tab[i] <= tab[i + 1]) {
		TR[i] = TR[i + 1];
		d = tab[i];
		c = 0;
		while (d * 4 <= tab[i + 1]) {
			d *= 4;
			c++;
		}
		if (c == 0) {
			jump[i] = jump[i + 1]; 
			up[i] = up[i + 1];
		} else {
			jump[i] = i;
			up[i] = c;
		}
	} else {
		d = tab[i + 1];
		c = 0;
		while (d < tab[i]) {
			d *= 4LL;
			c++;
		}
		r = 0;
		ind = i + 1;
		l = jump[ind];
		while (c > 0) {
			r += (jump[ind] - ind + 1) * 1LL * c;
			if (jump[ind] == n) break;
			c -= up[ind];
			if (c <= 0) break;
			ind = jump[ind] + 1;
		}
		if (c == 0 && jump[ind] != n) {
			ind = jump[ind] + 1;
			up[i] = up[ind];
		} else up[i] = -c;
		jump[i] = jump[ind];
		TR[i] = TR[i + 1] + r * 2;
	}
	//cout << i << " " << TR[i] << " " << jump[i] << " " << up[i] << endl;
}
for (i=1;i<=n;i++) tab[i] *= (-2);
TL[1] = 1;
jump[1] = 1;
for (i=2;i<=n;i++) {
	if (tab[i] >= tab[i - 1]) {
		TL[i] = TL[i - 1] + 1;
		d = tab[i];
		c = 0;
		while (d * 4 >= tab[i - 1]) {
			d *= 4;
			c++;
		}
		if (c == 0) {
			jump[i] = jump[i - 1]; 
			up[i] = up[i - 1];
		} else {
			jump[i] = i;
			up[i] = c;
		}
	} else {
		d = tab[i - 1];
		c = 0;
		while (d > tab[i]) {
			d *= 4LL;
			c++;
		}
		r = 0;
		ind = i - 1;
		l = jump[ind];
		while (c > 0) {
			r += (ind - jump[ind] + 1) * 1LL * c;
			if (jump[ind] == 1) break;
			c -= up[ind];
			if (c<=0) break;
			ind = jump[ind] - 1;
		}
		if (c == 0 && jump[ind] != 1) {
			ind = jump[ind] - 1;
			up[i] = up[ind];
		} else up[i] = -c;
		jump[i] = jump[ind];
		TL[i] = TL[i - 1] + r * 2 + 1;
	}
	//cout << i << " " << TL[i] << endl;
}
minn = min(TR[1], TL[n]);
for (i = 2;i<=n;i++) minn = min(minn, TR[i] + TL[i - 1]);
cout << minn << endl;
return 0;
}



Measured memory_bytes: 5888
n = int(input())
a = list(map(int, input().split(" ")))
b = list(map(int, input().split(" ")))

count = 0
next_b = 0
for i, ai in enumerate(a):
  #print(ai, next_b, count)
  if i < n:
    bi = b[i]
    if ai > next_b:
      ai = ai - next_b
      count += next_b
    else:
      count += ai
      ai = 0
      
    if ai < bi:
      count += ai
      next_b = bi -ai
    else:
      count += bi
      next_b = 0
  else:
    if ai > next_b:
      count += next_b
    else:
      count += ai
      
print(count)

Measured memory_bytes: 18624
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
//const int INF = 1<<29;
using namespace std;
struct UnionFind {
    vector<int> par;
    
    UnionFind(int N) : par(N){
        for (int i = 0; i < N; i++) par[i] = i;
    }
    
    int root (int x){
        if (par[x] == x) return x;
        else return par[x] = root(par[x]);
    // 再帰しつつpar[x]を大親に貼り直し
    }
    
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }
    
    bool same (int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main(){
    int x, y;
    cin >> x >> y;
    UnionFind tree(12);
    tree.unite(1, 3);
    tree.unite(3, 5);
    tree.unite(5, 7);
    tree.unite(7, 8);
    tree.unite(8, 10);
    tree.unite(10, 12);
    tree.unite(4, 6);
    tree.unite(6, 9);
    tree.unite(9, 11);
    
    if (tree.same(x, y)) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import itertools

n, m, q = map(int, input().split())
data = []
m_arange = list(range(1, m+1))
m = 0
ans = 0

for i in range(q):
    data.append(list(map(int, input().split())))

pattern = list(itertools.combinations_with_replacement(m_arange, n))


for row in pattern:
    for x in data:
        if row[x[1]-1] - row[x[0]-1]== x[2]:
            m += x[3]
    ans = max(ans, m)
    m = 0 

print(ans)

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

using namespace std;

#define ll long long

int main()
{
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif // ONLINE_JUDGE
	ll times=1;
	// cin>>times;
	while(times--)
	{
		ll a,b,c,d;
		cin>>a>>b>>c>>d;
		ll m1=max(a*c,a*d);
		ll m2=max(b*c,b*d);
		cout<<max(m1,m2);
	}
}

Measured memory_bytes: 3632
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)1e18;
const double PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,P;
	cin >> N >> P;
	vector<int> A(N,0);
	for(int i=0;i<N;++i){
		cin >> A[i];
	}
	vector< vector<LL> > dp(N+1,vector<LL>(2,0));
	dp[0][0] = 1;
	for(int i=0;i<N;++i){
		//dp[i+1]
		if( A[i]%2 == 0 ){
			dp[i+1][0] = dp[i][0]*2;
			dp[i+1][1] = dp[i][1]*2;
		}else{//1
			dp[i+1][0] = dp[i][0] + dp[i][1];
			dp[i+1][1] = dp[i][0] + dp[i][1];
		}
	}
	cout << dp[N][P] << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


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

int main(){
    int N; string S;
    scanf("%d", &N);
    cin >> S;

    if (S.length() <= N) cout << S << '\n';
    else {
        for (int i=0; i<N; i++)
            cout << S[i];
        cout << "...\n";
    }
    return 0;
}


Measured memory_bytes: 3692
#include <iostream>
#include <numeric>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <cstdlib>
#include <cmath>
 
#define repd(i,a,b); for(int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define ll long long int
 
 
using namespace std;
int main() {
  double n,k;
  cin >> n >> k;
  double sum=0;
  repd(i,1,n+1){
    if (i<k){
    sum += pow(0.5,ceil(log2(k/i)));
    }
    else {
    sum += 1;
    }
  }
  sum /= n;
  cout << setprecision(20) << sum;
    
 
 return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;


int main() {
    int n;
    string s;
    cin >> n >> s;
    if (n % 2) {
        cout << "No" << endl;
        return 0;
    }
    if (s.substr(0, n / 2) == s.substr(n / 2, n / 2)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define endl '\n'
#define mod 1000000007

using namespace std;

int main()
{
    ll n ,ans=1e18;
    cin>>n;
    vector<ll>v;
    for(ll i=1;i*i<=n;i++){
        if(n%i==0)v.push_back(i);
        if(n%i==0 &&n/i != i)v.push_back(n/i);}


    //cout<<v.size()<<endl;

    for(int i=0;i<v.size();i++)
    {
        ll other = n/v[i], otherc =n/v[i], vi=v[i];
       // cout<<v[i]<< ' '<<other<<' '<<other*v[i]<<endl;
        ll cnt1=0, cnt2=0;
        while(other)other/=10, cnt1++;
        while(v[i])v[i]/=10, cnt2++;
      //  if(max(cnt1, cnt2)>ans)cout<<vi<< ' ' <<otherc<<endl;
        ans= min(ans, max(cnt1, cnt2));
    }
    cout<<ans;
    return 0;
}


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

# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;
 
template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;



int main () {
	SpeedForce;
	cin >> n >> m;
	for (int i = 1; i <= n; i ++)
		cin >> a[i];
	for (int i = 1; i < n; i ++) {
		if (a[i] + a[i+1] >= m) {
			cout << "Possible\n";
			for (int j = 1; j < i; ++ j) {
                cout << j << '\n';
            }
 
            for (int j = n - 1; j >= i; -- j) {
            	cout << j << '\n';
            }
            exit(0);
		}
	}
	puts("Impossible");
   	return Accepted;
}

// B...a

Measured memory_bytes: 19328
/*--------------------------"SABUJ-JANA"------"JADAVPUR UNIVERSITY"--------*/
/*-------------------------------@greenindia-----------------------------------*/
/*---------------------- Magic. Do not touch.-----------------------------*/
/*------------------------------God is Great/\---------------------------------*/
#include <bits/stdc++.h>
using namespace std;
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
//cout<<fixed<<showpoint<<setprecision(12)<<ans<<endl;
#define dbg(x) cerr << #x << " = " << x << endl
#define endl "\n"
#define int long long int
#define double long double
#define pb push_back
#define mp make_pair
#define PI acos(-1)

//const int INF=1e9+5;//billion
int primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89};
string alpha = "abcdefghijklmnopqrstuvwxyz";
/*----------JU IS LOVE----------*/
//int power(int a,int b,int m){int ans=1;while(b){if(b&1)ans=(ans*a)%m;b/=2;a=(a*a)%m;}return ans;}
//int power(int a, int b){int ans=1;while(b){if(b&1)ans=ans*a;b/=2;a=a*a;}return ans;}

// int LIS(int arr[], int n) {

// 	if (n == 0) return 0;
// 	set<int> s;
// 	for (int i = 0; i < n; ++i)
// 	{
// 		/* code */
// 		auto ret = s.insert(arr[i]);
// 		set<int>::iterator it;

// 		if (ret.second)
// 			it = ret.first;

// 		it++;

// 		if (it == s.end())
// 			continue;
// 		else
// 			s.erase(it);

// 	}

// 	return s.size();


// }

int LIS(vector<int> const& a) {
    int n = a.size();
    const int INF = 1e9;
    vector<int> d(n+1, INF);
    d[0] = -INF;

    for (int i = 0; i < n; i++) {
        int j = upper_bound(d.begin(), d.end(), a[i]) - d.begin();
        if (d[j-1] <= a[i] && a[i] <= d[j])
            d[j] = a[i];
    }

    int ans = 0;
    for (int i = 0; i <= n; i++) {
        if (d[i] < INF)
            ans = i;
    }
    return ans;
}

signed main() {
 
	crap;


	int n;
	cin >> n;

	int arr[n];
	std::vector<int> v;
	for (int i = 0; i < n; ++i)
	{
		/* code */
		cin >> arr[i];

		arr[i] = -arr[i];
		v.push_back(arr[i]);
	}

	cout << LIS(v) << endl;

	return 0;
}






Measured memory_bytes: 2676
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		
		while (sc.hasNext()) {
			double k_500m = sc.nextDouble();
			double k_1000m = sc.nextDouble();
			
			if (k_500m < 35.50 && k_1000m < 71.00) {
				System.out.println("AAA");
			} else if (k_500m < 37.50 && k_1000m < 77.00) {
				System.out.println("AA");
			} else if (k_500m < 40.00 && k_1000m < 83.00) {
				System.out.println("A");
			} else if (k_500m < 43.00 && k_1000m < 89.00) {
				System.out.println("B");
			} else if (k_500m < 50.00 && k_1000m < 105.00) {
				System.out.println("C");
			} else if (k_500m < 55.00 && k_1000m < 116.00) {
				System.out.println("D");
			} else if (k_500m < 70.00 && k_1000m < 148.00) {
				System.out.println("E");
			} else {
				System.out.println("NA");
			}
		}
	}
}

Measured memory_bytes: 12000
import java.util.Scanner;

// Java8
public class Main {
	Scanner sc = new Scanner(System.in);

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	void run() throws Exception {
		long[][] f = new long[10][1001];
		f[0][0] = 1;
		for(int x=0; x<=100; x++) {
			for(int t=9; t>0; t--) {
				for(int i=0; i<=1000; i++) {
					if(i>=x) {
						f[t][i] += f[t-1][i-x];
					}
				}
			}
		}
		while(true) {
			int n = sc.nextInt();
			int s = sc.nextInt();
			if(n==0 && s==0) break;
			System.out.println(f[n][s]);
		}
	}
}


Measured memory_bytes: 26788
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      s: chars,
    }
    let mut win = 0;
    for i in 0..s.len() {
        if s[i] == 'o' {
            win += 1;
        }
    }
    win += 15 - s.len();
    if win >= 8 {
        println!("{}", "YES");
    } else {
        println!("{}", "NO");
    }
}


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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n;
  cin >> n;
  if(n >= 400 && n < 600)cout << 8 << endl;
  if(n >= 600 && n < 800)cout << 7 << endl;
  if(n >= 800 && n < 1000)cout << 6 << endl;
  if(n >= 1000 && n < 1200)cout << 5 << endl;
  if(n >= 1200 && n < 1400)cout << 4 << endl;
  if(n >= 1400 && n < 1600)cout << 3 << endl;
  if(n >= 1600 && n < 1800)cout << 2 << endl;
  if(n >= 1800 && n < 2000)cout << 1 << endl;


  return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
const ll INF=1e15;
#define int long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define fastio cin.tie(NULL); cout.tie(NULL); ios_base::sync_with_stdio(false)
const double pi = acos(-1.0);
int gcd (int a, int b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
int lcm (int a, int b) {
    return a / gcd(a, b) * b;
}

long long binpows(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)  //impar
            res = res * a;
        a = a * a;
        b >>= 1;  // /2
    }
    return res;
}
const int mod=1e9+7;
int binpow(int a, int b, int m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
//CHECAR SE PRECISA DE LONG LONG
vector<pair<int,int> > v;
int n,wq;
int dp[123456];
void solve(){
	for(int i=0; i<=1e5+1; i++)
		dp[i]=INF;
	cin>>n>>wq;
	v.resize(n);
	for(auto &i: v)cin>>i.first>>i.second;
	dp[0]=0;
	for(int i=0; i<n; i++){
		for(int j=1e5+1; j>=v[i].second; j--){
			dp[j]=min(dp[j],dp[j-v[i].second]+v[i].first);
		}
	}
	for(int i=1e5+1; i>=0; i--){
		if(dp[i]<=wq){
			cout<<i<<endl;
			return;
		}
	}
}
//revise as variaveis e a ordem nas funções
signed main(){
    int t=1;
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 4468